:root {
  --ink: #18314f;
  --muted: #61758b;
  --blue: #2876cf;
  --blue-dark: #15559f;
  --cream: #fff9ea;
  --paper: rgba(255, 255, 255, .96);
  --green: #238a5b;
  --red: #c84555;
  --gold: #e0a529;
  --purple: #7755b8;
  --line: #d9e4ef;
  --shadow: 0 16px 42px rgba(18, 45, 72, .24);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  display: grid;
  place-items: center;
  padding: 14px;
  overflow-x: hidden;
  background: #b9dff1;
  color: var(--ink);
  font-family: "Trebuchet MS", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
summary {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.game {
  width: min(1180px, 100%);
  overflow: hidden;
  border: 4px solid rgba(255, 255, 255, .86);
  border-radius: 28px;
  background: #132f4e;
  box-shadow: 0 25px 70px rgba(20, 52, 78, .3);
}

.topbar {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 14px;
  background: linear-gradient(90deg, #184f88, #2876cf);
  color: #fff;
}

.back-link,
.round-button {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, .18);
  color: #fff;
  text-decoration: none;
  cursor: pointer;
  font-size: 20px;
  font-weight: 1000;
}

.back-link:hover,
.round-button:hover {
  background: rgba(255, 255, 255, .3);
}

.round-button.speaking {
  background: rgba(139, 240, 181, .38);
  animation: speaker-pulse .8s ease-in-out infinite alternate;
}

@keyframes speaker-pulse {
  to {
    box-shadow: 0 0 0 7px rgba(139, 240, 181, .16);
    transform: scale(1.05);
  }
}

.title {
  min-width: 0;
  flex: 1;
}

.title small,
.title strong {
  display: block;
}

.title small {
  opacity: .82;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.title strong {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-size: clamp(16px, 2.2vw, 22px);
}

.phase-progress {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12px;
  font-weight: 1000;
}

.progress-dots {
  display: flex;
  gap: 5px;
}

.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, .3);
  transition: .25s ease;
}

.progress-dot.current {
  background: #fff;
  transform: scale(1.28);
}

.progress-dot.done {
  background: #8bf0b5;
}

.scene {
  position: relative;
  min-height: 610px;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  isolation: isolate;
  background: #d5effb;
}

.scene-image {
  position: absolute;
  inset: 0;
  z-index: -4;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  opacity: 0;
  transition: opacity .45s ease, filter .3s ease;
  user-select: none;
  -webkit-user-drag: none;
}

.scene-image.ready {
  opacity: 1;
}

.fallback-room {
  position: absolute;
  inset: 0;
  z-index: -5;
  overflow: hidden;
  background:
    radial-gradient(circle at 18% 12%, rgba(255, 255, 255, .72), transparent 25%),
    linear-gradient(#b9dded 0 63%, #b78862 63%);
  transition: filter .3s ease;
}

.fallback-room::before {
  content: "";
  position: absolute;
  inset: 0 0 34%;
  background:
    linear-gradient(90deg, transparent 0 8%, rgba(255,255,255,.16) 8% 9%, transparent 9% 91%, rgba(255,255,255,.12) 91% 92%, transparent 92%),
    repeating-linear-gradient(0deg, rgba(52, 94, 118, .055) 0 2px, transparent 2px 70px);
}

.fallback-window {
  position: absolute;
  left: 7%;
  top: 12%;
  width: 24%;
  height: 35%;
  border: 9px solid #f6fbff;
  border-radius: 8px;
  background:
    linear-gradient(90deg, transparent 47%, #f6fbff 47% 53%, transparent 53%),
    linear-gradient(transparent 47%, #f6fbff 47% 53%, transparent 53%),
    linear-gradient(#80c8e8 58%, #6fae69 58%);
  box-shadow: 0 8px 18px rgba(29, 59, 76, .16);
}

.fallback-cabinet {
  position: absolute;
  right: 6%;
  top: 16%;
  width: 18%;
  height: 47%;
  border: 7px solid #6e4934;
  border-radius: 10px 10px 3px 3px;
  background:
    radial-gradient(circle at 48% 49%, #d7b47f 0 5px, transparent 6px),
    linear-gradient(90deg, #9d6e4b 49%, #6e4934 49% 52%, #9d6e4b 52%);
  box-shadow: 0 13px 20px rgba(42, 36, 31, .22);
}

.fallback-door {
  position: absolute;
  right: 28%;
  top: 13%;
  width: 15%;
  height: 51%;
  border: 8px solid #f4eee3;
  background:
    radial-gradient(circle at 84% 51%, #d6a635 0 5px, transparent 6px),
    linear-gradient(90deg, #7a9fba, #91b3ca);
  box-shadow: inset 0 0 0 3px rgba(38, 70, 91, .14);
}

.fallback-clock {
  position: absolute;
  left: 49%;
  top: 11%;
  width: 64px;
  aspect-ratio: 1;
  border: 8px solid #f8f5ec;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 5px 12px rgba(36, 56, 71, .16);
}

.fallback-clock::before,
.fallback-clock::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 4px;
  border-radius: 3px;
  background: #294660;
  transform-origin: 50% 100%;
}

.fallback-clock::before {
  height: 18px;
  transform: translate(-50%, -100%);
}

.fallback-clock::after {
  height: 15px;
  transform: translate(-50%, -100%) rotate(120deg);
}

.fallback-rug {
  position: absolute;
  left: 22%;
  right: 15%;
  bottom: 2%;
  height: 27%;
  border-radius: 50%;
  background: radial-gradient(ellipse, #d6c0e8 0 54%, #b69acb 55% 66%, transparent 67%);
  transform: perspective(250px) rotateX(58deg);
}

.fallback-table {
  position: absolute;
  left: 39%;
  bottom: 9%;
  width: 31%;
  height: 16%;
  border-radius: 50% 50% 12px 12px;
  background: linear-gradient(#c99261 0 33%, #96623f 34%);
  box-shadow: 0 18px 0 -8px #704832;
}

.fallback-character {
  position: absolute;
  left: 18%;
  bottom: 8%;
  width: 90px;
  height: 190px;
  border-radius: 44px 44px 24px 24px;
  background: linear-gradient(#263f6f 0 24%, #d5a26f 25% 42%, #805cae 43% 76%, #405a88 77%);
  box-shadow: 0 13px 20px rgba(32, 48, 65, .2);
}

.fallback-character i {
  position: absolute;
  left: 11px;
  top: -17px;
  width: 68px;
  height: 70px;
  border-radius: 48% 48% 43% 43%;
  background: #4b3027;
}

.fallback-character b {
  position: absolute;
  left: 50%;
  top: 64px;
  display: grid;
  place-items: center;
  width: 31px;
  height: 31px;
  border-radius: 50%;
  background: #fff;
  color: #67489d;
  transform: translateX(-50%);
}

.scene-shade {
  position: absolute;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(8, 29, 47, .02), rgba(8, 29, 47, .12));
}

.scene-effects {
  position: absolute;
  inset: 0;
  z-index: 15;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -8%;
  width: 9px;
  height: 18px;
  border-radius: 3px;
  animation: confetti-fall 1.8s ease-in forwards;
}

@keyframes confetti-fall {
  from {
    transform: translateY(-30px) rotate(0);
  }
  to {
    transform: translateY(720px) rotate(720deg);
  }
}

.speech-bubble {
  position: absolute;
  left: 3%;
  top: 4%;
  z-index: 12;
  width: min(420px, 45%);
  padding: 16px 18px 14px;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: var(--paper);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(12px) scale(.97);
  transition: .27s ease;
}

.speech-bubble::after {
  content: "";
  position: absolute;
  left: 48px;
  bottom: -15px;
  width: 24px;
  height: 24px;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: inherit;
  transform: rotate(45deg);
}

.speech-bubble.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
}

.bubble-speaker {
  float: right;
  width: 38px;
  height: 38px;
  margin: -4px -5px 4px 9px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
}

.speaker-name {
  margin-bottom: 5px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: .07em;
  text-transform: uppercase;
}

.bubble-en {
  margin: 0;
  font-size: clamp(17px, 2.1vw, 24px);
  font-weight: 1000;
  line-height: 1.2;
}

.bubble-tr,
.translation {
  display: none;
}

.bubble-tr {
  margin: 8px 0 0;
  padding-top: 7px;
  border-top: 1px dashed rgba(24, 49, 79, .3);
  color: #536a80;
  font-size: 14px;
  font-weight: 700;
}

.show-tr .bubble-tr,
.show-tr .translation {
  display: block;
}

.interaction-panel {
  position: absolute;
  left: 2.5%;
  right: 2.5%;
  bottom: 2.5%;
  z-index: 10;
  max-height: 60%;
  overflow-x: hidden;
  overflow-y: auto;
  border: 3px solid rgba(255, 255, 255, .92);
  border-radius: 24px;
  background: rgba(246, 251, 255, .95);
  box-shadow: var(--shadow);
  opacity: 0;
  visibility: hidden;
  transform: translateY(22px);
  transition: .3s ease;
  scrollbar-width: thin;
}

.interaction-panel.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.panel-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 13px 16px 11px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .96);
}

.panel-step {
  flex: 0 0 auto;
  min-width: 38px;
  height: 38px;
  display: grid;
  place-items: center;
  border-radius: 13px;
  background: #e5f1ff;
  color: var(--blue-dark);
  font-weight: 1000;
}

.panel-copy {
  min-width: 0;
  flex: 1;
}

.panel-copy h2 {
  margin: 0 0 3px;
  font-size: clamp(17px, 2vw, 21px);
}

.panel-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
}

.panel-copy .translation {
  margin-top: 4px;
  color: #796991;
}

.game[data-phase="build"] .panel-copy p {
  font-size: 15px;
}

.panel-body {
  padding: 12px 14px 14px;
}

.collect-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(250px, .72fr);
  gap: 12px;
}

.object-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
}

.object-card,
.action-card,
.word-block,
.event-card {
  position: relative;
  border: 2px solid #d5e1ec;
  background: #fff;
  color: var(--ink);
  cursor: grab;
  transition: .2s ease;
}

.object-card {
  min-height: 93px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 7px 5px;
  border-radius: 15px;
  text-align: center;
}

.object-card:hover,
.action-card:hover,
.word-block:hover,
.event-card:hover {
  border-color: var(--blue);
  transform: translateY(-2px);
  box-shadow: 0 7px 15px rgba(30, 78, 119, .13);
}

.object-card.selected {
  border-color: var(--green);
  background: #eaf8f0;
}

.object-card.wrong {
  border-color: var(--red);
  background: #fff0f1;
  animation: shake .35s ease;
}

.object-visual {
  position: relative;
  width: 46px;
  height: 46px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 12px;
  background: #eff5fa;
}

.object-visual img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.object-visual .fallback-icon {
  color: #46637c;
  font-size: 24px;
}

.object-card strong {
  font-size: 12px;
  line-height: 1.08;
}

.object-card small {
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
}

.party-box,
.drop-target,
.sentence-answer {
  border: 3px dashed #99b5cc;
  background:
    repeating-linear-gradient(135deg, rgba(255,255,255,.82) 0 13px, rgba(235,245,252,.82) 13px 26px);
}

.sentence-answer.wrong {
  border-color: var(--red);
  background: #fff0f1;
  animation: shake .35s ease;
}

.party-box {
  min-height: 100%;
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: 18px;
}

.party-box.drag-over,
.drop-target.drag-over,
.sentence-answer.drag-over {
  border-color: var(--green);
  background: #e6f7ed;
}

.box-title,
.target-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13px;
  font-weight: 1000;
}

.box-title span {
  color: var(--purple);
}

.box-items,
.target-items {
  min-height: 80px;
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 6px;
}

.box-chip,
.target-chip,
.answer-chip {
  border: 1px solid #c7d7e5;
  border-radius: 999px;
  padding: 7px 9px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.box-chip.wrong,
.target-chip.wrong {
  border-color: var(--red);
  background: #fff0f1;
  color: #a62f3f;
}

.box-empty {
  margin: auto;
  color: #7890a5;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 10px;
}

.primary-button,
.secondary-button {
  max-width: 100%;
  border: 0;
  border-radius: 999px;
  padding: 11px 18px;
  cursor: pointer;
  font-weight: 1000;
  line-height: 1.2;
  overflow-wrap: anywhere;
  white-space: normal;
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: #fff;
  box-shadow: 0 9px 19px rgba(39, 117, 207, .27);
}

.primary-button.success {
  background: linear-gradient(135deg, #2ca36c, #1b7a50);
}

.primary-button:disabled {
  opacity: .45;
  cursor: not-allowed;
  box-shadow: none;
}

.secondary-button {
  border: 2px solid #c9d9e6;
  background: #fff;
  color: var(--ink);
}

.plan-status {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 5px;
  padding: 8px 14px;
  border-bottom: 1px solid var(--line);
  background: #f1f7fc;
}

.plan-status span {
  overflow: hidden;
  border-radius: 8px;
  padding: 6px 4px;
  background: #dfe9f2;
  color: #7890a5;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 9px;
  font-weight: 900;
}

.plan-status span.done {
  background: #dff4e8;
  color: #26764f;
}

.plan-status span.current {
  background: #e5efff;
  color: var(--blue-dark);
  box-shadow: inset 0 0 0 2px #80afe0;
}

.plan-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(230px, .65fr);
  gap: 12px;
}

.plan-layout > *,
.collect-layout > *,
.recap-layout > *,
.build-wrap > *,
.tell-layout > * {
  min-width: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.action-card {
  min-height: 82px;
  display: grid;
  grid-template-columns: 34px 1fr;
  align-items: center;
  gap: 8px;
  padding: 9px;
  border-radius: 14px;
  text-align: left;
}

.action-card.with-image {
  min-height: 142px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: 8px;
  text-align: center;
}

.action-media {
  position: relative;
  width: 100%;
  min-height: 82px;
  flex: 1;
  overflow: hidden;
  border-radius: 11px;
  background: #e9f1f8;
}

.action-media img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.invitation-media {
  background:
    radial-gradient(circle at 50% 14%, rgba(255, 255, 255, .9), transparent 34%),
    linear-gradient(145deg, #edf7ff, #d8e9f7);
}

.invitation-card {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border: 0;
  border-radius: 11px;
  background: #fff8dc;
}

.invitation-card img {
  position: static;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 15%;
}

.invitation-card b {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: var(--blue-dark);
  font-size: 34px;
}

.invitation-envelope {
  position: absolute;
  right: 7px;
  bottom: 6px;
  width: 52px;
  height: 32px;
  overflow: hidden;
  border: 1px solid #b89047;
  border-radius: 4px 4px 7px 7px;
  background: linear-gradient(145deg, #fffaf0, #f4dfb7);
  box-shadow: 0 2px 6px rgba(24, 49, 79, .24);
}

.invitation-envelope::before,
.invitation-envelope::after {
  content: "";
  position: absolute;
  top: -23%;
  width: 70%;
  height: 115%;
  border-top: 2px solid rgba(177, 142, 76, .55);
  background: rgba(255, 250, 240, .58);
}

.invitation-envelope::before {
  left: -35%;
  transform: rotate(31deg);
}

.invitation-envelope::after {
  right: -35%;
  transform: rotate(-31deg);
}

.balloon-media {
  display: block;
  background: linear-gradient(#dff3ff, #f7fcff);
}

.balloon-media i {
  position: absolute;
  width: 38px;
  height: 48px;
  border-radius: 50% 50% 46% 46%;
  background: var(--balloon-colour);
  box-shadow: inset -7px -8px 10px rgba(15, 45, 75, .14);
}

.balloon-media i::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 100%;
  width: 1px;
  height: 36px;
  background: rgba(52, 76, 98, .48);
}

.balloon-media i:nth-child(1) { left: 20%; top: 24%; transform: rotate(-8deg); }
.balloon-media i:nth-child(2) { left: 36%; top: 9%; transform: rotate(-3deg); }
.balloon-media i:nth-child(3) { left: 51%; top: 20%; transform: rotate(5deg); }
.balloon-media i:nth-child(4) { left: 63%; top: 5%; transform: rotate(9deg); }
.balloon-media i:nth-child(5) { left: 75%; top: 28%; transform: rotate(12deg); }
.balloon-media.blue-balloons { --balloon-colour: #3e8fe5; }
.balloon-media.blue-balloons i:nth-child(even) { --balloon-colour: #69b7f2; }
.balloon-media.pink-balloons { --balloon-colour: #ec67a7; }
.balloon-media.pink-balloons i:nth-child(even) { --balloon-colour: #f49bc3; }

.object-art {
  background:
    radial-gradient(circle at 50% 30%, rgba(255, 255, 255, .95), transparent 34%),
    linear-gradient(145deg, #fff7e8, #e9f4fb);
}

.cake-art::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 18px;
  width: 94px;
  height: 42px;
  border-radius: 12px 12px 8px 8px;
  background:
    linear-gradient(#fff5f7 0 28%, #f28aae 29% 40%, #ffd7a8 41% 72%, #dc77a0 73% 84%, #ffd7a8 85%);
  box-shadow: 0 6px 0 #d2dde5, 0 9px 12px rgba(24, 49, 79, .18);
  transform: translateX(-50%);
}

.cake-art::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 11px;
  width: 126px;
  height: 10px;
  border-radius: 50%;
  background: #f8fdff;
  border: 2px solid #b7cad9;
  transform: translateX(-50%);
}

.candles-art i {
  position: absolute;
  bottom: 20px;
  width: 12px;
  height: 48px;
  border-radius: 5px 5px 3px 3px;
  background: repeating-linear-gradient(135deg, #4d88df 0 7px, #fff 8px 13px);
  box-shadow: 0 5px 8px rgba(24, 49, 79, .16);
}

.candles-art i::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: calc(100% + 2px);
  width: 13px;
  height: 19px;
  border-radius: 60% 40% 60% 40%;
  background: linear-gradient(#fff5a5, #f2a51f 70%);
  transform: translateX(-50%) rotate(8deg);
}

.candles-art i:nth-child(1) { left: 28%; }
.candles-art i:nth-child(2) { left: 42%; background-color: #e7659c; }
.candles-art i:nth-child(3) { left: 56%; }
.candles-art i:nth-child(4) { left: 70%; background-color: #e7659c; }

.plates-art i {
  position: absolute;
  left: 50%;
  width: 112px;
  height: 38px;
  border: 5px solid #bed4e4;
  border-radius: 50%;
  background: #fbfeff;
  box-shadow: 0 5px 9px rgba(24, 49, 79, .14);
  transform: translateX(-50%);
}

.plates-art i:nth-child(1) { top: 17px; }
.plates-art i:nth-child(2) { top: 29px; }
.plates-art i:nth-child(3) { top: 41px; }
.plates-art i:nth-child(4) { display: none; }

.action-media .action-fallback {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}

.action-card.with-image > span:last-child {
  padding: 7px 3px 1px;
}

.action-card.portrait-card {
  min-height: 126px;
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  align-items: center;
  padding: 8px;
  text-align: left;
}

.portrait-card .portrait-media {
  width: 82px;
  height: 108px;
  min-height: 108px;
  background: #f3e7d8;
}

.portrait-card .portrait-media img {
  object-fit: cover;
  object-position: center top;
}

.action-card.portrait-card > span:last-child {
  padding: 6px 8px;
}

.action-card.portrait-card strong {
  font-size: 14px;
}

.action-card.portrait-card small {
  font-size: 11px;
}

.action-card.selected {
  border-color: var(--green);
  background: #eaf8f0;
}

.action-card.wrong {
  border-color: var(--red);
  background: #fff0f1;
  animation: shake .35s ease;
}

.action-icon {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e9f1f8;
  color: var(--blue-dark);
  font-weight: 1000;
}

.action-card strong {
  display: block;
  font-size: 12px;
  line-height: 1.15;
}

.action-card small {
  display: none;
  margin-top: 3px;
  color: var(--muted);
  font-size: 9px;
}

.show-tr .action-card small {
  display: block;
}

.drop-target {
  min-width: 0;
  min-height: 118px;
  padding: 12px;
  border-radius: 18px;
}

.target-slot {
  min-width: 41px;
  min-height: 38px;
  display: grid;
  place-items: center;
  border: 2px dashed #b4c8d8;
  border-radius: 11px;
  color: #7990a4;
  font-size: 11px;
  font-weight: 900;
}

.feedback-line {
  min-height: 20px;
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.feedback-line.error {
  color: var(--red);
}

.feedback-line.success {
  color: var(--green);
}

.recap-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.event-bank,
.event-order {
  min-height: 156px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 9px;
  border-radius: 15px;
  background: #edf4f9;
}

.event-card {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 11px;
  text-align: left;
}

.event-card b {
  flex: 0 0 auto;
  width: 25px;
  height: 25px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #e3edf5;
  color: var(--blue-dark);
}

.event-card span {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.25;
}

.event-card.placed > span:not(.reorder-controls) {
  min-width: 0;
  flex: 1;
}

.reorder-controls {
  flex: 0 0 auto;
  display: flex;
  gap: 3px;
  margin-left: auto;
}

.reorder-controls button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  padding: 0;
  border: 1px solid #b8cde0;
  border-radius: 8px;
  background: #f5faff;
  color: var(--blue-dark);
  cursor: pointer;
  font-weight: 1000;
}

.reorder-controls button:hover:not(:disabled) {
  border-color: var(--blue);
  background: #e4f3ff;
}

.reorder-controls button:disabled {
  opacity: .32;
  cursor: default;
}

.event-card small {
  display: none;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.25;
}

.show-tr .event-card small {
  display: block;
}

.event-order {
  border: 2px dashed #9eb7cb;
  background: rgba(255,255,255,.66);
}

.event-order .event-card.wrong {
  border-color: var(--red);
  background: #fff0f1;
}

.event-order.drag-over {
  border-color: var(--blue);
  background: #eaf6ff;
}

.build-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 210px;
  gap: 12px;
}

.sentence-card {
  min-width: 0;
}

.sentence-meter {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.sentence-meter div {
  flex: 1;
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #dde8f1;
}

.sentence-meter i {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--blue), var(--purple));
  transition: width .3s ease;
}

.sentence-answer {
  min-height: 61px;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 9px;
  border-radius: 15px;
}

.answer-chip {
  border-radius: 10px;
  padding: 9px 11px;
  font-size: 14px;
  font-weight: 1000;
}

.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-top: 8px;
}

.word-block {
  border-radius: 11px;
  padding: 10px 13px;
  font-size: 14px;
  font-weight: 1000;
}

.word-block.used {
  display: none;
}

.sentence-support {
  margin: 7px 0 0;
  color: #6a7f94;
  font-size: 12px;
  font-weight: 800;
  line-height: 1.4;
}

.sentence-card .feedback-line {
  font-size: 14px;
  line-height: 1.4;
}

.story-book-mini {
  max-height: 178px;
  overflow: auto;
  padding: 9px;
  border-radius: 15px;
  background: #fff9e7;
  box-shadow: inset 0 0 0 2px #ebdcb2;
}

.story-book-mini strong {
  display: block;
  margin-bottom: 6px;
  color: #8b681b;
  font-size: 11px;
  text-transform: uppercase;
}

.story-book-mini p {
  margin: 0 0 5px;
  color: #5c6670;
  font-size: 10px;
  font-weight: 700;
}

.story-book-mini p.current {
  color: var(--blue-dark);
}

.tell-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 250px;
  gap: 12px;
}

.story-page {
  min-height: 118px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 15px;
  border: 2px solid #eadcb8;
  border-radius: 18px;
  background: #fffaf0;
}

.story-page small {
  color: #9a7623;
  font-weight: 1000;
  text-transform: uppercase;
}

.story-page h2 {
  margin: 6px 0;
  font-size: clamp(20px, 2.6vw, 29px);
  line-height: 1.18;
}

.story-page p {
  display: none;
  margin: 3px 0 0;
  color: var(--muted);
  font-weight: 700;
}

.show-tr .story-page p {
  display: block;
}

.tell-controls {
  display: grid;
  gap: 7px;
  align-content: center;
}

.tell-controls button {
  width: 100%;
}

.opening {
  position: absolute;
  inset: 0;
  z-index: 30;
  padding: 3%;
  background: linear-gradient(to bottom, rgba(15, 44, 68, .05), rgba(15, 44, 68, .14));
  transition: .35s ease;
}

.opening.hide {
  opacity: 0;
  visibility: hidden;
}

.opening-card {
  position: relative;
  width: min(440px, 94%);
  padding: 16px 18px 15px;
  border: 3px solid var(--ink);
  border-radius: 26px;
  background: rgba(255, 255, 255, .97);
  text-align: left;
  box-shadow: var(--shadow);
}

.opening-card::after {
  content: "";
  position: absolute;
  left: 48px;
  bottom: -15px;
  width: 24px;
  height: 24px;
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  background: inherit;
  transform: rotate(45deg);
}

.opening-speaker {
  float: right;
  width: 40px;
  height: 40px;
  margin: -3px -4px 5px 10px;
  border: 0;
  border-radius: 50%;
  background: var(--blue);
  color: #fff;
  cursor: pointer;
  font-size: 17px;
}

.kicker {
  display: block;
  margin-bottom: 5px;
  color: var(--blue-dark);
  font-size: 12px;
  font-weight: 1000;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
}

.opening-english {
  margin: 0;
  color: var(--ink);
  font-size: clamp(18px, 2.3vw, 25px);
  font-weight: 1000;
  line-height: 1.2;
}

.opening-translation {
  display: none;
  margin: 7px 0 0;
  padding-top: 7px;
  border-top: 1px dashed rgba(24, 49, 79, .3);
  color: #4d657e;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.45;
}

.show-tr .opening-translation {
  display: block;
}

.opening-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 9px;
}

.toast {
  position: absolute;
  left: 50%;
  top: 46%;
  z-index: 35;
  max-width: min(620px, 88%);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(24, 49, 79, .94);
  color: #fff;
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  text-align: center;
  transform: translate(-50%, -50%) scale(.9);
  transition: .22s ease;
  font-size: 13px;
  font-weight: 1000;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.toolbar {
  min-height: 57px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 9px;
  padding: 8px 12px;
  background: #f6fbff;
}

.preview-nav {
  display: none;
  align-items: center;
  gap: 5px;
  color: var(--blue-dark);
  font-size: 10px;
  font-weight: 1000;
}

.preview-nav.show {
  display: flex;
}

.preview-nav select {
  max-width: 112px;
  border: 2px solid #9dc3e5;
  border-radius: 999px;
  padding: 7px 9px;
  background: #eaf6ff;
  color: var(--ink);
  font: inherit;
  cursor: pointer;
}

.tool-button {
  border: 2px solid #c8ddef;
  border-radius: 999px;
  padding: 8px 13px;
  background: #fff;
  color: var(--ink);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.tool-button:hover,
.tool-button.active {
  border-color: var(--blue);
  background: #e6f4ff;
  color: var(--blue-dark);
}

.pulse {
  animation: pulse 1s ease-in-out infinite alternate;
}

@keyframes pulse {
  from {
    box-shadow: 0 0 0 0 rgba(255, 213, 67, .72);
  }
  to {
    box-shadow: 0 0 0 10px rgba(255, 213, 67, 0);
  }
}

@keyframes shake {
  25% { transform: translateX(-5px); }
  50% { transform: translateX(5px); }
  75% { transform: translateX(-3px); }
}

@media (max-width: 1120px) {
  .plan-layout {
    grid-template-columns: minmax(0, 1fr) minmax(210px, .48fr);
  }

  .action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .plan-status span {
    font-size: 8px;
  }
}

@media (max-width: 900px) {
  .scene {
    min-height: 650px;
    aspect-ratio: auto;
  }

  .object-grid {
    grid-template-columns: repeat(4, 1fr);
  }

  .action-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px) {
  .plan-layout {
    grid-template-columns: 1fr;
  }

  .drop-target {
    min-height: 104px;
  }
}

@media (max-width: 680px) {
  body {
    display: block;
    padding: 0;
    background: #132f4e;
  }

  .game {
    width: 100%;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    min-height: 57px;
    padding: 7px 9px;
  }

  .back-link,
  .round-button {
    width: 38px;
    height: 38px;
  }

  .phase-progress > span {
    display: none;
  }

  .scene {
    min-height: 0;
    flex: 1;
    aspect-ratio: auto;
  }

  .scene-image {
    object-fit: cover;
    object-position: 27% center;
    background: #d5effb;
  }

  .speech-bubble {
    left: 4%;
    top: 3%;
    width: min(90%, 420px);
    padding: 13px 14px 12px;
    border-radius: 22px;
  }

  .bubble-en {
    font-size: 18px;
  }

  .interaction-panel {
    left: 1.5%;
    right: 1.5%;
    bottom: 1.5%;
    max-height: 69%;
    border-radius: 19px;
  }

  .panel-head {
    padding: 10px 11px 9px;
  }

  .panel-body {
    padding: 9px;
  }

  .collect-layout,
  .plan-layout,
  .recap-layout,
  .build-wrap,
  .tell-layout {
    grid-template-columns: 1fr;
  }

  .object-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .object-card {
    min-height: 82px;
  }

  .party-box {
    min-height: 128px;
  }

  .plan-status {
    overflow-x: auto;
    grid-template-columns: repeat(7, minmax(72px, 1fr));
  }

  .story-book-mini {
    display: none;
  }

  .toolbar {
    min-height: 58px;
    gap: 5px;
    padding: 7px 5px;
  }

  .tool-button {
    padding: 8px 9px;
    font-size: 10px;
  }
}

@media (max-width: 390px) {
  .title small {
    display: none;
  }

  .object-grid {
    grid-template-columns: repeat(2, 1fr);
  }

}

@media (max-width: 330px) {
  .action-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-height: 650px) and (orientation: landscape) {
  body {
    display: block;
    padding: 0;
    background: #132f4e;
  }

  .game {
    width: 100%;
    min-height: 100svh;
    display: flex;
    flex-direction: column;
    border: 0;
    border-radius: 0;
  }

  .topbar {
    min-height: 52px;
    padding-block: 5px;
  }

  .back-link,
  .round-button {
    width: 38px;
    height: 38px;
  }

  .scene {
    min-height: 0;
    flex: 1;
    aspect-ratio: auto;
  }

  .speech-bubble {
    top: 2%;
    max-height: 34%;
    overflow: auto;
    padding: 11px 13px 10px;
  }

  .bubble-en {
    font-size: 17px;
  }

  .interaction-panel {
    left: 1%;
    right: 1%;
    bottom: 1%;
    max-height: 86%;
    border-radius: 18px;
  }

  .panel-head {
    padding: 8px 11px 7px;
  }

  .panel-step {
    min-width: 34px;
    height: 34px;
  }

  .panel-body {
    padding: 8px 10px 10px;
  }

  .plan-status {
    padding: 6px 10px;
  }

  .plan-layout {
    grid-template-columns: minmax(0, 1fr) minmax(185px, .46fr);
    gap: 8px;
  }

  .action-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 6px;
  }

  .action-card {
    min-height: 64px;
    padding: 7px;
  }

  .action-card.with-image {
    min-height: 64px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    padding: 6px;
    text-align: left;
  }

  .action-media {
    width: 46px;
    height: 46px;
    min-height: 46px;
  }

  .action-card.with-image > span:last-child {
    padding: 0;
  }

  .drop-target {
    min-height: 98px;
    padding: 9px;
  }

  .target-items {
    min-height: 38px;
  }

  .feedback-line {
    min-height: 17px;
    margin-top: 4px;
  }

  .panel-actions {
    margin-top: 5px;
  }

  .toolbar {
    min-height: 50px;
    padding-block: 5px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
  }
}
