:root {
  --bg: #0f1022;
  --surface: #171933;
  --text: #f2f4ff;
  --primary: #7f6dff;
  --primary-dark: #5d48eb;
  --border: #3a3d70;
  --ok: #1c8c4a;
  --bad: #b53a3a;
  --surface-soft: #23264b;
  --accent: #3ed2ff;
  --accent-2: #ff68d1;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(circle at 10% 20%, rgba(62, 210, 255, 0.22), transparent 35%),
    radial-gradient(circle at 90% 10%, rgba(255, 104, 209, 0.2), transparent 32%),
    radial-gradient(circle at 70% 85%, rgba(127, 109, 255, 0.2), transparent 40%),
    var(--bg);
  color: var(--text);
}

.container {
  width: min(960px, 92vw);
  margin: 0 auto;
}

.topbar {
  background: linear-gradient(120deg, rgba(23, 25, 51, 0.95), rgba(30, 34, 70, 0.95));
  border-bottom: 1px solid rgba(127, 109, 255, 0.5);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 0;
}

h1 {
  font-size: 1.2rem;
  margin: 0;
}

.panel {
  margin: 1.25rem 0;
  background: linear-gradient(155deg, rgba(26, 30, 60, 0.97), rgba(20, 22, 45, 0.97));
  border: 1px solid rgba(127, 109, 255, 0.35);
  border-radius: 12px;
  padding: 1rem;
  box-shadow:
    0 12px 34px rgba(0, 0, 0, 0.32),
    inset 0 0 0 1px rgba(62, 210, 255, 0.08);
}

.result-toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 999;
  padding: 1.2rem 2.2rem;
  min-width: min(92vw, 520px);
  border-radius: 16px;
  color: #fff;
  text-align: center;
  font-size: 1.45rem;
  font-weight: 700;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  transition: opacity 0.75s ease, transform 0.75s ease;
  animation: toast-slide-in 0.65s ease-out;
}

.result-emoji {
  font-size: 1.35em;
  margin-right: 0.25rem;
  vertical-align: -0.03em;
}

.result-toast.ok {
  background: linear-gradient(135deg, #1f9d56, #30c56f);
}

.result-toast.bad {
  background: linear-gradient(135deg, #bb3346, #e05263);
}

.result-toast.hide {
  opacity: 0;
  transform: translate(-50%, 120vh);
}

@keyframes toast-slide-in {
  from {
    opacity: 0;
    transform: translate(-50%, -70vh);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.quiz-card {
  border: 1px solid rgba(62, 210, 255, 0.35);
  border-radius: 10px;
  padding: 1rem;
  background: linear-gradient(145deg, rgba(39, 44, 85, 0.75), rgba(27, 31, 63, 0.75));
  margin-bottom: 1.5rem;
}

.quiz-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.quiz-icon {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.quiz-meta {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.clock-canvas {
  position: relative;
  z-index: 3;
  display: block;
  width: min(90vw, 340px);
  height: auto;
  margin: 0 auto;
  background: #fdfdff;
  border: 2px solid rgba(127, 109, 255, 0.48);
  border-radius: 50%;
  box-shadow:
    0 0 0 8px rgba(62, 210, 255, 0.08),
    0 18px 40px rgba(0, 0, 0, 0.35);
  touch-action: none;
}

.clock-sky {
  position: relative;
  width: min(94vw, 520px);
  margin: 1rem auto;
  padding: 22px 18px 20px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  overflow: hidden;
}

.clock-sky.day {
  background: radial-gradient(circle at 35% 25%, #fff8bd 0%, #8fd9ff 45%, #58b8ff 100%);
  box-shadow:
    0 0 30px rgba(124, 211, 255, 0.45),
    inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

.clock-sky.night {
  background:
    radial-gradient(circle at 20% 20%, rgba(180, 196, 255, 0.35), transparent 40%),
    linear-gradient(180deg, #0f1f5c 0%, #1a2361 45%, #291a5f 100%);
  box-shadow:
    0 0 30px rgba(86, 92, 204, 0.45),
    inset 0 0 0 1px rgba(204, 215, 255, 0.16);
}

.sky-stars,
.sky-clouds,
.sky-sun,
.sky-moon {
  position: absolute;
  pointer-events: none;
}

.sky-stars {
  inset: 0;
  z-index: 1;
  opacity: 0;
}

.clock-sky.night .sky-stars {
  opacity: 0.95;
}

.sky-star {
  position: absolute;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 8px rgba(255, 255, 255, 0.9);
  animation: twinkle 2.6s ease-in-out infinite;
}

.sky-comet {
  position: absolute;
  width: 240px;
  height: 6px;
  border-radius: 999px;
  background:
    radial-gradient(circle at 96% 50%, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0) 55%),
    linear-gradient(90deg, rgba(255, 255, 255, 0), rgba(255, 255, 255, 0.95));
  filter: blur(0.1px) drop-shadow(0 0 16px rgba(170, 210, 255, 0.7));
  opacity: 0;
  animation-name: comet-fly-left;
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.sky-comet::before {
  content: "";
  position: absolute;
  left: 0;
  top: -5px;
  width: 100%;
  height: 16px;
  border-radius: 999px;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0),
    rgba(255, 115, 205, 0.35) 20%,
    rgba(255, 203, 106, 0.4) 40%,
    rgba(88, 234, 215, 0.4) 60%,
    rgba(96, 165, 255, 0.45) 80%,
    rgba(255, 255, 255, 0.6) 100%
  );
  filter: blur(4px);
  opacity: 0.9;
}

.sky-comet::after {
  content: "";
  position: absolute;
  right: 6px;
  top: -8px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffffff 0%, rgba(255, 255, 255, 0.35) 62%, transparent 100%);
  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.95),
    0 0 24px rgba(140, 210, 255, 0.7);
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.15;
    transform: scale(0.8);
  }
  50% {
    opacity: 1;
    transform: scale(1.15);
  }
}

@keyframes comet-fly-left {
  0% {
    opacity: 0;
    transform: translateX(0) scale(0.9);
  }
  12% {
    opacity: 1;
  }
  70% {
    opacity: 0.7;
    transform: translateX(140vw) scale(1.03);
  }
  100% {
    opacity: 0;
    transform: translateX(140vw) scale(1.05);
  }
}

.sky-comet.from-right {
  transform: scaleX(-1);
  animation-name: comet-fly-right;
}

@keyframes comet-fly-right {
  0% {
    opacity: 0;
    transform: translateX(0) scaleX(-1) scale(0.9);
  }
  12% {
    opacity: 1;
  }
  70% {
    opacity: 0.7;
    transform: translateX(-140vw) scaleX(-1) scale(1.03);
  }
  100% {
    opacity: 0;
    transform: translateX(-140vw) scaleX(-1) scale(1.05);
  }
}

.sky-clouds {
  inset: 0;
  z-index: 1;
  opacity: 0;
}

.clock-sky.day .sky-clouds {
  opacity: 1;
}

.sky-cloud {
  position: absolute;
  height: 28px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 2px 10px rgba(255, 255, 255, 0.25);
  filter: blur(0.2px);
  animation-timing-function: linear;
  animation-iteration-count: infinite;
}

.sky-cloud::before,
.sky-cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.72);
}

.sky-cloud::before {
  width: 24px;
  height: 24px;
  top: -10px;
  left: 18px;
}

.sky-cloud::after {
  width: 30px;
  height: 30px;
  top: -14px;
  left: 38px;
}

@keyframes cloud-drift-right {
  from {
    transform: translateX(-120px);
  }
  to {
    transform: translateX(620px);
  }
}

@keyframes cloud-drift-left {
  from {
    transform: translateX(620px);
  }
  to {
    transform: translateX(-140px);
  }
}

.sky-sun {
  width: 78px;
  height: 78px;
  top: 8px;
  right: 16px;
  border-radius: 50%;
  opacity: 0;
  z-index: 2;
  background: radial-gradient(circle at 35% 30%, #fffce9 0%, #ffe778 42%, #ffbf3a 100%);
  box-shadow:
    0 0 22px rgba(255, 205, 86, 0.85),
    0 0 52px rgba(255, 212, 104, 0.65),
    0 0 90px rgba(255, 221, 120, 0.35);
}

.clock-sky.day .sky-sun {
  opacity: 1;
}

.sky-moon {
  width: 64px;
  height: 64px;
  top: 14px;
  right: 18px;
  border-radius: 50%;
  opacity: 0;
  z-index: 2;
  background: radial-gradient(circle at 28% 30%, #fff7c7 0%, #ffd86a 58%, #e4ae35 100%);
  box-shadow: 0 0 18px rgba(255, 214, 102, 0.55);
}

.sky-moon::after {
  content: "";
  position: absolute;
  inset: 0;
  left: 18px;
  border-radius: 50%;
  background: linear-gradient(180deg, #1a2361 0%, #291a5f 100%);
}

.clock-sky.night .sky-moon {
  opacity: 1;
}

.inputs-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.92rem;
}

input,
select,
button {
  font: inherit;
}

input,
select {
  width: 100%;
  border: 1px solid rgba(127, 109, 255, 0.6);
  border-radius: 8px;
  padding: 0.55rem 0.65rem;
  background: rgba(23, 26, 52, 0.9);
  color: var(--text);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(62, 210, 255, 0.2);
}

button,
.btn-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 8px;
  padding: 0.6rem 0.9rem;
  background: linear-gradient(135deg, var(--primary), var(--accent-2));
  color: white;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 8px 18px rgba(127, 109, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease, filter 0.15s ease;
}

button:hover,
.btn-link:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
  box-shadow: 0 12px 24px rgba(127, 109, 255, 0.45);
}

button.secondary {
  background: linear-gradient(135deg, #4f7cf4, #3ed2ff);
}

.new-game-form {
  margin-top: 0.8rem;
}

.lang-form {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hand-controls {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.step-controls {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.8rem;
}

.step-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.step-row span {
  min-width: 70px;
}

.small-btn {
  background: linear-gradient(135deg, #4e5673, #6f79a5);
}

.small-btn.active {
  background: linear-gradient(135deg, var(--primary), var(--accent-2));
}

.current-set-time {
  margin-top: 0;
  margin-bottom: 1rem;
}

.hidden-set-time {
  display: none;
}

.translation-prompt {
  display: grid;
  gap: 0.6rem;
  margin-bottom: 1rem;
}

.prompt-label {
  font-size: 0.9rem;
  opacity: 0.8;
}

.prompt-card {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 76px;
  padding: 0.8rem 1rem;
  border-radius: 12px;
  border: 1px solid rgba(127, 109, 255, 0.35);
  background: rgba(23, 26, 52, 0.9);
  font-size: 1.2rem;
  font-weight: 600;
  text-align: center;
}

.prompt-card.image img {
  width: 72px;
  height: 72px;
}

.translation-form {
  display: grid;
  gap: 0.7rem;
}

.match-hint {
  margin-top: 0;
  opacity: 0.8;
}

.match-board {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2rem;
  padding: 1rem;
  border-radius: 16px;
  border: 1px solid rgba(127, 109, 255, 0.35);
  background: rgba(23, 26, 52, 0.8);
  overflow: hidden;
}

.match-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.match-column {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  z-index: 2;
}

.match-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.6;
}

.match-item {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 56px;
  padding: 0.55rem 0.65rem;
  border-radius: 12px;
  border: 1px solid rgba(127, 109, 255, 0.4);
  background: rgba(34, 38, 75, 0.9);
  cursor: pointer;
  text-align: center;
  font-weight: 600;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.match-item img {
  width: 48px;
  height: 48px;
}

.match-item:hover {
  transform: translateY(-1px);
  border-color: rgba(62, 210, 255, 0.6);
  box-shadow: 0 8px 16px rgba(0, 0, 0, 0.25);
}

.match-item.selected {
  border-color: rgba(255, 244, 41, 0.85);
  box-shadow: 0 0 0 3px rgba(255, 244, 41, 0.25);
}

.match-item.paired {
  border-color: rgba(62, 210, 255, 0.75);
}

.score-big {
  font-size: 2rem;
  margin-top: 0;
}

.results-list {
  display: grid;
  gap: 0.6rem;
}

.result-item {
  border: 1px solid rgba(127, 109, 255, 0.35);
  border-radius: 10px;
  padding: 0.6rem;
  background: rgba(35, 38, 75, 0.6);
}

.result-item.ok {
  border-color: rgba(28, 140, 74, 0.75);
  box-shadow: inset 0 0 0 1px rgba(28, 140, 74, 0.25);
}

.result-item.bad {
  border-color: rgba(181, 58, 58, 0.75);
  box-shadow: inset 0 0 0 1px rgba(181, 58, 58, 0.25);
}

.result-icon {
  width: 36px;
  height: 36px;
  vertical-align: middle;
  margin-left: 0.4rem;
}

.actions-row {
  margin-top: 1rem;
  display: flex;
  gap: 0.6rem;
  flex-wrap: wrap;
}

@media (max-width: 640px) {
  .topbar-inner {
    flex-direction: column;
    align-items: flex-start;
  }

  .inputs-grid {
    grid-template-columns: 1fr;
  }

  .match-board {
    grid-template-columns: 1fr;
  }

  .match-lines {
    display: none;
  }
}
