:root { color-scheme: light dark; }
* { box-sizing: border-box; }

body {
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  margin: 0;
  height: 100dvh;
  overflow: hidden;
}

/* ── Game layout: full-bleed image ── */
.game-layout {
  position: relative;
  height: 100dvh;
  width: 100%;
  overflow: hidden;
}

.img-panel {
  position: absolute;
  inset: 0;
  background: #000;
}
.img-panel img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* ── Image slide-in animation ── */
@keyframes slide-in-right {
  from { transform: translateX(100%); }
  to   { transform: translateX(0); }
}
.img-panel img.slide-in {
  animation: slide-in-right 0.7s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

/* ── Glassmorphism card base ── */
.overlay-card {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  color: #fff;
  padding: 12px 16px;
}

/* ── Top-left: world + activity ── */
.overlay-tl {
  position: absolute;
  top: 16px;
  left: 16px;
  pointer-events: none;
}
.overlay-tl .meta {
  font-size: 11px;
  opacity: 0.55;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.overlay-tl .world-name {
  font-size: 15px;
  font-weight: 600;
  margin: 2px 0 1px;
}
.overlay-tl .activity-num {
  font-size: 12px;
  opacity: 0.5;
}

/* ── Top-right: floating timer ── */
.overlay-tr {
  position: absolute;
  top: 16px;
  right: 16px;
}
.timer-float {
  position: relative;
  width: 68px;
  height: 68px;
  filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.55));
}
.timer-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.timer-track {
  fill: none;
  stroke: rgba(255, 255, 255, 0.15);
  stroke-width: 5;
}
.timer-fill {
  fill: none;
  stroke: rgba(80, 220, 140, 0.95);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.1s linear;
}
.timer-num {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.8);
}

/* ── Bottom overlay stack ── */
.overlay-bottom {
  position: absolute;
  bottom: 16px;
  left: 16px;
  right: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* ── Drop slots ── */
.drop-area {
  display: flex;
  gap: 8px;
}
.drop-slot {
  flex: 1;
  min-width: 0;
  min-height: 52px;
  border: 2px dashed rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: border-color 0.15s, background 0.15s;
  cursor: default;
  overflow: hidden;
}
.drop-slot.drag-over {
  border-color: rgba(80, 160, 255, 0.8);
  background: rgba(80, 160, 255, 0.15);
}
.drop-slot.filled {
  border-style: solid;
  border-color: rgba(80, 220, 140, 0.5);
}

/* ── Shake & vanish (wrong word) ── */
@keyframes shake-vanish {
  0%   { transform: translateX(0);    opacity: 1; }
  15%  { transform: translateX(-9px); }
  30%  { transform: translateX(9px);  }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px);  opacity: 0.7; }
  80%  { transform: translateX(-3px); opacity: 0.3; }
  100% { transform: translateX(0);    opacity: 0; }
}
.word-chip.shake {
  animation: shake-vanish 0.5s ease forwards;
  pointer-events: none;
}

/* ── Flash white then lock (correct word) ── */
@keyframes flash-correct {
  0%   { background: rgba(255, 255, 255, 0.15); color: #fff;  border-color: rgba(255,255,255,0.25); }
  35%  { background: rgba(255, 255, 255, 0.95); color: #111;  border-color: transparent; }
  100% { background: rgba(80, 220, 140, 0.3);   color: #fff;  border-color: rgba(80,220,140,0.5); }
}
.word-chip.flash-correct {
  animation: flash-correct 0.45s ease forwards;
  pointer-events: none;
}
.word-chip.locked {
  background: rgba(80, 220, 140, 0.25) !important;
  border-color: rgba(80, 220, 140, 0.5) !important;
  color: #fff !important;
  pointer-events: none;
  cursor: default;
}

/* ── Word bank + restart row ── */
.bank-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.word-bank {
  flex: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

/* ── Word chips ── */
.word-chip {
  padding: 8px 14px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  cursor: grab;
  font-size: 14px;
  user-select: none;
  touch-action: none;
  transition: background 0.15s, outline 0.1s;
  white-space: nowrap;
}
.word-chip:hover { background: rgba(255, 255, 255, 0.22); }
.word-chip.selected {
  outline: 2px solid rgba(80, 180, 255, 0.9);
  background: rgba(80, 180, 255, 0.2);
}
.word-chip.dragging { opacity: 0.35; cursor: grabbing; }

/* Chip placed inside a slot — expands to fill the full slot area */
.drop-slot .word-chip {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 4px 8px;
  font-size: 13px;
  margin: 0;
  border-color: rgba(255, 255, 255, 0.15);
  cursor: pointer;
  white-space: normal;
}

/* ── Restart button ── */
.restart-form { margin: 0; flex-shrink: 0; }
.restart-btn {
  padding: 8px 13px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  transition: background 0.15s;
}
.restart-btn:hover { background: rgba(255, 255, 255, 0.18); }

/* ── Banner ── */
.banner {
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0, 180, 100, 0.3);
  border: 1px solid rgba(0, 220, 120, 0.35);
  color: #fff;
  font-size: 14px;
}
.banner-time {
  opacity: 0.65;
  font-size: 12px;
  margin-left: 6px;
}

/* ── Shared ── */
.kbd {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas,
    "Liberation Mono", "Courier New", monospace;
  font-size: 0.95em;
}
.divider {
  height: 1px;
  background: rgba(127, 127, 127, 0.18);
  flex-shrink: 0;
}

/* ── Done screen ── */
.done-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 32px 16px 64px;
}
.done-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.done-score {
  font-size: 40px;
  font-weight: 800;
  line-height: 1;
}
.card {
  border: 1px solid rgba(127, 127, 127, 0.22);
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
}
.small {
  font-size: 13px;
  opacity: 0.75;
}
.break {
  padding: 10px 0;
}
.done-btn {
  padding: 11px 18px;
  border-radius: 10px;
  border: 1px solid rgba(60, 140, 255, 0.35);
  background: rgba(60, 140, 255, 0.15);
  cursor: pointer;
  font-size: 15px;
  font-weight: 600;
  color: inherit;
}

/* ── Done hero ── */
.done-hero {
  text-align: center;
  padding: 28px 0 8px;
}
.done-trophy {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(255,200,50,0.18), rgba(255,160,0,0.1));
  border: 1.5px solid rgba(255,190,40,0.35);
  color: #f0a500;
  margin-bottom: 14px;
}
.done-hero-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  opacity: 0.45;
}
.done-hero-title {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 0;
  letter-spacing: -0.02em;
}

/* ── Stat bubbles ── */
.done-bubbles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-top: 16px;
}
.done-bubble {
  border-radius: 16px;
  padding: 18px 12px 14px;
  text-align: center;
  border: 1px solid transparent;
}
.done-bubble-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-bottom: 10px;
}
.done-bubble-val {
  font-size: 28px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: -0.03em;
}
.done-bubble-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  opacity: 0.55;
  margin-top: 5px;
}
.done-bubble--green {
  background: rgba(50,210,130,0.10);
  border-color: rgba(50,210,130,0.22);
}
.done-bubble--green .done-bubble-icon { background: rgba(50,210,130,0.15); color: #2ec97a; }
.done-bubble--green .done-bubble-val  { color: #2ec97a; }
.done-bubble--blue {
  background: rgba(60,140,255,0.10);
  border-color: rgba(60,140,255,0.22);
}
.done-bubble--blue .done-bubble-icon { background: rgba(60,140,255,0.15); color: #4a8fff; }
.done-bubble--blue .done-bubble-val  { color: #4a8fff; }
.done-bubble--orange {
  background: rgba(255,140,40,0.10);
  border-color: rgba(255,140,40,0.22);
}
.done-bubble--orange .done-bubble-icon { background: rgba(255,140,40,0.15); color: #f07a1a; }
.done-bubble--orange .done-bubble-val  { color: #f07a1a; }
.done-bubble--purple {
  background: rgba(160,90,255,0.10);
  border-color: rgba(160,90,255,0.22);
}
.done-bubble--purple .done-bubble-icon { background: rgba(160,90,255,0.15); color: #a35ef0; }
.done-bubble--purple .done-bubble-val  { color: #a35ef0; }

/* ── Activity row ── */
.done-activity-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
}
.done-activity-badge {
  flex-shrink: 0;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background: rgba(50,210,130,0.15);
  border: 1.5px solid rgba(50,210,130,0.3);
  color: #2ec97a;
  font-size: 13px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.done-activity-body {
  flex: 1;
  min-width: 0;
}
.done-activity-words {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.done-word-chip {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Courier New", monospace;
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(127,127,127,0.10);
  border: 1px solid rgba(127,127,127,0.18);
}
.done-activity-time {
  flex-shrink: 0;
  font-size: 12px;
  font-weight: 600;
  opacity: 0.45;
  padding: 3px 8px;
  border-radius: 6px;
  border: 1px solid rgba(127,127,127,0.15);
}

/* ── Error screen ── */
.error-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 32px 16px;
}
.error-msg {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 80, 80, 0.12);
  border: 1px solid rgba(255, 80, 80, 0.25);
  font-size: 13px;
}

/* ── In-game home back-link ── */
.home-back-link {
  display: block;
  margin-top: 8px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.45);
  text-decoration: none;
  pointer-events: auto;
  transition: color 0.15s;
}
.home-back-link:hover { color: rgba(255, 255, 255, 0.9); }

/* ── Homepage ── */
.home-layout {
  position: relative;
  height: 100dvh;
  overflow: hidden;
}
.home-layout .img-panel img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}
.home-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: flex-end;
  padding: 32px 24px;
}
.home-card {
  background: rgba(0, 0, 0, 0.52);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 18px;
  color: #fff;
  padding: 28px 28px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 340px;
  width: 100%;
}
.home-world-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  opacity: 0.5;
}
.home-title {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.15;
  margin-top: 2px;
}
.home-play-btn {
  display: block;
  margin-top: 18px;
  background: #fff;
  color: #111;
  text-align: center;
  text-decoration: none;
  font-weight: 700;
  font-size: 16px;
  border-radius: 12px;
  padding: 14px 0;
  transition: opacity 0.15s;
}
.home-play-btn:hover { opacity: 0.88; }
.home-links {
  display: flex;
  justify-content: center;
  gap: 24px;
  margin-top: 12px;
}
.home-links a {
  color: rgba(255, 255, 255, 0.55);
  text-decoration: none;
  font-size: 13px;
  transition: color 0.15s;
}
.home-links a:hover { color: #fff; }

/* ── About page ── */
.about-wrap {
  max-width: 600px;
  margin: 0 auto;
  padding: 40px 20px 80px;
  overflow-y: auto;
  height: 100dvh;
}
.about-back {
  display: inline-block;
  font-size: 13px;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  margin-bottom: 28px;
}
.about-back:hover { opacity: 0.6; }

/* Plain text links inside about-wrap paragraphs */
.about-wrap p a {
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.about-wrap p a:hover { opacity: 0.6; }
.about-wrap h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 6px;
}
.about-wrap h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 24px 0 6px;
}
.about-wrap p {
  font-size: 14px;
  line-height: 1.65;
  opacity: 0.8;
  margin: 0 0 12px;
}
.about-play-btn {
  display: inline-block;
  margin-top: 28px;
  padding: 12px 24px;
  border-radius: 12px;
  border: 1px solid rgba(60, 140, 255, 0.35);
  background: rgba(60, 140, 255, 0.12);
  font-size: 15px;
  font-weight: 600;
  color: inherit;
  text-decoration: none;
  transition: background 0.15s;
}
.about-play-btn:hover { background: rgba(60, 140, 255, 0.22); }

/* More Games section */
.more-games-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.more-games-list a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid rgba(128, 128, 128, 0.2);
  background: rgba(128, 128, 128, 0.07);
  color: inherit;
  text-decoration: none;
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s;
}
.more-games-list a:hover { background: rgba(128, 128, 128, 0.15); }
.more-games-list img {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  flex-shrink: 0;
}

/* ── Home — multi-world list ── */
.home-worlds-list {
  margin-top: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.home-world-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.10);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  text-decoration: none;
  font-size: 15px;
  font-weight: 600;
  transition: background 0.15s;
}
.home-world-row:hover { background: rgba(255, 255, 255, 0.18); }
.home-world-arrow {
  opacity: 0.45;
  font-size: 14px;
}

/* ── Done — main menu button ── */
.done-menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 14px 28px;
  border-radius: 14px;
  font-size: 16px;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: -0.01em;
  transition: opacity 0.15s, transform 0.1s;
  background: #111;
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.18);
}
.done-menu-btn:hover { opacity: 0.82; transform: translateY(-1px); }
.done-menu-btn:active { opacity: 0.95; transform: translateY(0); }

/* Smaller pill variant used in the topbar */
.done-menu-btn--sm {
  padding: 9px 16px;
  font-size: 14px;
  border-radius: 10px;
  gap: 7px;
}

/* Ghost/outline variant for secondary action */
.done-menu-btn--alt {
  background: transparent;
  color: inherit;
  border-color: rgba(127, 127, 127, 0.3);
  box-shadow: none;
  cursor: pointer;
}
.done-menu-btn--alt:hover { background: rgba(127, 127, 127, 0.08); }

@media (prefers-color-scheme: dark) {
  .done-menu-btn {
    background: #fff;
    color: #111;
    border-color: rgba(0, 0, 0, 0.08);
  }
  .done-menu-btn--alt {
    background: transparent;
    color: inherit;
    border-color: rgba(255, 255, 255, 0.2);
  }
  .done-menu-btn--alt:hover { background: rgba(255, 255, 255, 0.08); }
}

