.brand,
.topbar-actions,
.tray-slots,
.stars {
  display: flex;
  align-items: center;
}

.brand { gap: 9px; font-size: 1.05rem; font-weight: 900; letter-spacing: -0.02em; }
.brand img {
  padding: 4px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.82);
  filter: drop-shadow(0 3px 4px rgba(92, 55, 39, 0.14));
  image-rendering: auto;
}
.topbar-actions { gap: 8px; }

.icon-button {
  width: var(--tap-size);
  height: var(--tap-size);
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  box-shadow: var(--shadow-small);
  font-weight: 900;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
}

.control-icon-wrap {
  position: relative;
  width: 27px;
  height: 27px;
  display: grid;
  place-items: center;
}

.control-icon-fallback {
  visibility: hidden;
  color: var(--ink-soft);
  font-size: 0.58rem;
  font-weight: 950;
  letter-spacing: -0.02em;
}

.control-icon-wrap.is-missing-art .control-icon-fallback { visibility: visible; }

.control-icon {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  opacity: 0.78;
}

.icon-button[aria-pressed="false"] .sound-icon-wrap::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 12px;
  width: 23px;
  height: 3px;
  border-radius: 999px;
  background: #87364e;
  box-shadow: 0 0 0 2px var(--paper);
  rotate: -45deg;
}

.icon-button:disabled {
  opacity: 0.48;
  cursor: default;
  box-shadow: none;
}

.mission-card,
.order-tray {
  padding: 12px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: var(--shadow-small);
}

.eyebrow {
  display: block;
  margin-bottom: 2px;
  color: var(--berry);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 0; font-size: clamp(1.1rem, 3vw, 1.45rem); line-height: 1.12; }
h2 { margin-bottom: 8px; font-size: 1.15rem; }

.mission-copy { min-width: 0; }
.mission-copy h1 { overflow-wrap: anywhere; }

#mission-title:focus-visible {
  outline: none;
  text-decoration: underline 3px rgba(40, 126, 170, 0.72);
  text-underline-offset: 5px;
}

.mission-instruction {
  margin: 4px 0 0;
  color: var(--berry);
  font-size: 0.84rem;
  font-weight: 850;
}

.mission-instruction.is-retry { color: #87364e; }

.shift-progress {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 850;
}

.shift-progress-dots { display: flex; gap: 4px; }
.shift-progress-dots i {
  width: 9px;
  height: 9px;
  border: 2px solid rgba(185, 75, 107, 0.32);
  border-radius: 50%;
  background: transparent;
}
.shift-progress-dots i.is-complete {
  border-color: var(--berry);
  background: var(--berry);
}
.shift-progress-dots i.is-current {
  box-shadow: 0 0 0 2px rgba(185, 75, 107, 0.14);
}

.playfield-copy {
  position: absolute;
  top: 16px;
  left: 50%;
  translate: -50% 0;
  display: grid;
  width: max-content;
  max-width: 80%;
  text-align: center;
  color: rgba(52, 38, 31, 0.72);
  font-weight: 900;
}

.playfield-copy small { font-weight: 700; }

.is-running .static-preview {
  display: none;
}

.no-script-message {
  position: absolute;
  inset: 50% auto auto 50%;
  translate: -50% -50%;
  width: min(260px, 80%);
  margin: 0;
  padding: 16px;
  border-radius: var(--radius-small);
  background: var(--paper);
  box-shadow: var(--shadow-small);
  text-align: center;
  font-weight: 800;
}

.game-choice {
  width: var(--game-target);
  height: var(--game-target);
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.8);
  box-shadow: 0 8px 0 rgba(255, 255, 255, 0.46), 0 12px 24px rgba(62, 71, 67, 0.18);
  cursor: default;
}

.game-choice img { width: 70px; height: 70px; object-fit: contain; }

.helper-preview {
  position: absolute;
  width: 72px;
  height: 96px;
  background: url("../../assets/characters/adventurer.png") 0 0 / 648px 480px no-repeat;
  filter: drop-shadow(0 7px 5px rgba(52, 38, 31, 0.2));
}

.choice-control {
  position: absolute;
  width: var(--game-target);
  height: var(--game-target);
  padding: 0;
  translate: -50% -50%;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: transparent;
  pointer-events: none;
}

.choice-control[aria-disabled="true"] { cursor: default; }

.choice-control:focus-visible {
  outline: 5px solid #176f9b;
  outline-offset: 4px;
  background: rgba(255, 255, 255, 0.2);
  box-shadow: 0 0 0 9px rgba(255, 255, 255, 0.76);
}

.order-tray { min-height: 78px; }
.tray-slots { gap: 8px; }
.tray-slot,
.tray-slots > span {
  width: 48px;
  height: 48px;
  display: grid;
  place-items: center;
  border: 3px dashed rgba(110, 90, 79, 0.28);
  border-radius: 14px;
  background: var(--cream);
}

.tray-slots img,
.tray-item {
  width: 86%;
  height: 86%;
  object-fit: contain;
  filter: drop-shadow(0 3px 3px rgba(52, 38, 31, 0.15));
}
.tray-slot.is-dropping img { animation: tray-drop 220ms ease-out both; }
.stars { gap: 5px; color: #8a5d00; font-weight: 900; }
.stars img { width: 30px; height: 28px; object-fit: contain; }

.session-timer {
  min-width: 58px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.session-timer[hidden] { display: none; }
.session-timer.is-ending { color: #9a3030; }

.celebration {
  align-items: center;
  gap: 12px;
  min-width: min(300px, calc(100vw - 24px));
  padding: 13px 18px;
  border: 1px solid rgba(138, 93, 0, 0.18);
  border-radius: 20px;
  background: rgba(255, 250, 241, 0.97);
  box-shadow: var(--shadow);
  color: var(--ink);
}

.celebration[hidden] { display: none; }

.celebration.is-visible,
.celebration[data-state="visible"] {
  display: flex;
  animation: celebration-arrive 240ms ease-out both;
}

.celebration-art { width: 48px; height: 48px; object-fit: contain; }

.celebration strong { display: block; font-size: 1.1rem; }

@keyframes celebration-arrive {
  from { opacity: 0; transform: translateY(-10px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes tray-drop {
  from { opacity: 0.2; transform: translateY(-14px) scale(0.72); }
  70% { transform: translateY(2px) scale(1.08); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.surface-dialog {
  width: min(680px, calc(100% - 24px - env(safe-area-inset-left) - env(safe-area-inset-right)));
  max-height: calc(100svh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 0;
  border: 0;
  border-radius: var(--radius-large);
  background: transparent;
}

.surface-dialog[hidden] { display: none; }
.surface-dialog::backdrop { background: rgba(52, 38, 31, 0.52); backdrop-filter: blur(4px); }
.dialog-card {
  max-height: calc(100svh - 24px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: clamp(22px, 5vw, 40px);
  border-radius: var(--radius-large);
  background: var(--cream);
  box-shadow: var(--shadow);
}
.dialog-card > h2 { margin-bottom: 20px; font-size: clamp(1.55rem, 5vw, 2.2rem); }
#intro-title { margin-bottom: 6px; }
.dialog-lede { margin-bottom: 18px; color: var(--ink-soft); font-weight: 750; }

.profile-grid,
.character-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

.profile-grid button,
.character-grid button {
  min-height: 126px;
  display: grid;
  place-items: center;
  gap: 4px;
  padding: 12px 8px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--paper);
  box-shadow: var(--shadow-small);
  cursor: pointer;
}

.profile-grid button:hover,
.character-grid button:hover { border-color: var(--peach-strong); }
.character-grid button.is-selected,
.character-grid button[aria-pressed="true"] {
  border-color: var(--berry);
  background: #fff2f5;
  box-shadow: 0 0 0 3px rgba(185, 75, 107, 0.14), var(--shadow-small);
}
.profile-grid img {
  width: 54px;
  height: 54px;
  object-fit: contain;
  filter: drop-shadow(0 4px 4px rgba(92, 55, 39, 0.12));
}
.profile-grid small { color: var(--ink-soft); }

.character-crop {
  width: 72px;
  height: 96px;
  background-repeat: no-repeat;
  background-size: 648px 480px;
}
.character-crop.adventurer { background-image: url("../../assets/characters/adventurer.png"); }
.character-crop.person { background-image: url("../../assets/characters/person.png"); }
.character-crop.robot { background-image: url("../../assets/characters/robot.png"); }

.primary-button {
  min-height: 56px;
  width: 100%;
  margin-top: 18px;
  border: 0;
  border-radius: 18px;
  background: var(--berry);
  color: white;
  font-weight: 900;
  box-shadow: 0 5px 0 #87364e;
  cursor: pointer;
}

.dialog-actions { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: 10px; margin-top: 18px; }
.dialog-actions .primary-button { margin-top: 0; }
.secondary-button {
  min-height: 56px;
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--paper);
  font-weight: 900;
  cursor: pointer;
}
.profile-cancel-button { width: 100%; margin-top: 14px; }

.summary-card {
  background:
    linear-gradient(rgba(255, 250, 241, 0.92), rgba(255, 250, 241, 0.92)),
    url("../../assets/v2/ui/panel-beige-light.png") center / 100% 100% no-repeat;
  text-align: center;
}
.summary-card > h2 { margin-bottom: 6px; }
.summary-reward {
  width: min(360px, 100%);
  margin: 20px auto 8px;
  padding: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  border: 2px solid rgba(138, 93, 0, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.78);
  box-shadow: var(--shadow-small);
}
.summary-reward img {
  width: 72px;
  height: 72px;
  object-fit: contain;
  filter: drop-shadow(0 5px 5px rgba(92, 55, 39, 0.16));
}
.summary-reward strong,
.summary-reward span { display: block; }
.summary-reward strong { font-size: 1.15rem; }
.summary-reward span { margin-top: 4px; color: var(--ink-soft); font-weight: 750; }

.settings-card > h2 { margin-bottom: 6px; }

.settings-list {
  display: grid;
  gap: 12px;
}

.setting-row,
.setting-select,
.setting-group,
.help-details {
  margin: 0;
  padding: 14px 16px;
  border: 2px solid var(--line);
  border-radius: var(--radius-small);
  background: rgba(255, 255, 255, 0.76);
}

.setting-row,
.setting-select {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.setting-row strong,
.setting-row small,
.setting-select strong,
.setting-select small { display: block; }

.setting-row small,
.setting-select small,
.setting-group p,
.help-details p {
  margin: 3px 0 0;
  color: var(--ink-soft);
  font-size: 0.86rem;
  font-weight: 700;
}

.setting-group legend,
.help-details summary { font-weight: 900; }

.setting-toggle,
.segmented-control button {
  min-width: 68px;
  min-height: 46px;
  padding: 8px 12px;
  border: 2px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  font-weight: 900;
  cursor: pointer;
}

.setting-toggle[aria-pressed="true"],
.segmented-control button[aria-pressed="true"] {
  border-color: var(--berry);
  background: #fff2f5;
  color: #87364e;
}

.segmented-control {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.setting-select select {
  min-height: 46px;
  max-width: 150px;
  padding: 6px 32px 6px 10px;
  border: 2px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  color: var(--ink);
  font: inherit;
  font-weight: 800;
}

.help-details summary { min-height: 44px; display: flex; align-items: center; cursor: pointer; }
.compact-button { width: 100%; min-height: 48px; margin-top: 12px; }

@media (min-width: 800px) {
  .order-tray h2 { font-size: 1.4rem; }
  .order-tray {
    background:
      linear-gradient(rgba(255, 255, 255, 0.86), rgba(255, 250, 241, 0.9)),
      url("../../assets/v2/ui/panel-beige-light.png") center / 100% 100% no-repeat;
  }
  .tray-slots { margin: 12px 0; justify-content: center; }
  .tray-slot, .tray-slots > span { width: 78px; height: 78px; border-radius: 20px; }
  .stars {
    justify-content: center;
    margin-top: auto;
    padding-top: 18px;
    border-top: 2px solid rgba(110, 90, 79, 0.12);
    font-size: 1.2rem;
  }
}

@media (min-width: 800px) and (min-height: 651px) {
  .mission-copy {
    width: 100%;
    flex: 1;
    display: grid;
    grid-template:
      "eyebrow progress" auto
      "title progress" auto
      "instruction progress" auto /
      minmax(0, 1fr) auto;
    column-gap: 28px;
  }
  .mission-copy > .eyebrow { grid-area: eyebrow; }
  .mission-copy > h1 { grid-area: title; }
  .mission-copy > .mission-instruction { grid-area: instruction; }
  .mission-copy > .shift-progress {
    grid-area: progress;
    align-self: center;
    align-items: flex-end;
    flex-direction: column;
    margin: 0;
  }
  .order-tray .tray-slots {
    flex: 1;
    align-items: center;
  }
  .order-tray .session-timer { align-self: center; }
}

@media (max-width: 520px) {
  .mission-card { padding: 10px 12px; }
  .order-tray { padding: 9px 12px; }
  .order-tray h2 { display: none; }
  .tray-slot, .tray-slots > span { width: 42px; height: 42px; }
  .profile-grid { grid-template-columns: 1fr; }
  .profile-grid button { min-height: 92px; }
  .character-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .character-grid button { min-height: 118px; padding: 8px 3px; font-size: 0.82rem; }
  .character-crop { width: 64px; height: 86px; background-size: 576px 427px; }
  .dialog-actions { grid-template-columns: 1fr; }
  .summary-reward { margin-top: 14px; padding: 14px; }
  .summary-reward img { width: 60px; height: 60px; }
  .settings-card { padding: 20px 16px; }
  .setting-row, .setting-select { align-items: flex-start; }
  .setting-select { display: grid; }
  .setting-select select { width: 100%; max-width: none; }
}

@media (max-height: 650px) and (orientation: landscape) {
  .settings-card { padding: 16px 20px; }
  .settings-card > h2 { font-size: 1.45rem; }
  .settings-card .dialog-lede { margin-bottom: 10px; }
  .settings-list { grid-template-columns: 1fr 1fr; gap: 8px; }
  .setting-row, .setting-select, .setting-group, .help-details { padding: 9px 11px; }
  .settings-card > .primary-button { margin-top: 10px; }
}
