/* ==========================================================================
   goigoi Quest / Go - v3 UI Shell
   ========================================================================== */
:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  --color-primary: #3f7cda;
  --color-primary-dark: #285ca7;
  --color-accent: #ff9f1c;
  --color-success: #43aa8b;
  --color-danger: #e76f51;

  --ui-wood-dark: #7b4b2b;
  --ui-wood-light: #b87a44;
  --ui-felt-base: #efe2c8;
  --ui-felt-deep: #d7c09c;
  --ui-felt-bright: #f7edd8;
  --ui-paper: rgba(255, 250, 240, 0.95);
  --ui-ink: #4c3321;
  --ui-ink-soft: rgba(76, 51, 33, 0.72);
  --ui-border: rgba(110, 78, 48, 0.16);
  --ui-overlay: rgba(28, 18, 10, 0.62);
  --ui-shadow-soft: 0 14px 30px rgba(76, 51, 33, 0.12);
  --ui-shadow-strong: 0 24px 70px rgba(28, 18, 10, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0;
}

body {
  position: relative;
  overflow: hidden;
  /* Vietnamese-capable Latin fonts first so ward names (e.g. "Phường 19") keep their
     diacritics under lang="ja"; CJK fonts follow for per-glyph fallback on JP text. */
  font-family: "Segoe UI", -apple-system, BlinkMacSystemFont, "Helvetica Neue", "Roboto", "Noto Sans", Arial, "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Noto Sans JP", sans-serif;
  color: var(--ui-ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.6), rgba(255, 255, 255, 0) 48%),
    linear-gradient(180deg, #f7f1e7 0%, #efe3d0 52%, #ead8bd 100%);
}

img {
  display: block;
  max-width: 100%;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(63, 124, 218, 0.28);
  outline-offset: 2px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.56;
  box-shadow: none;
  transform: none;
}

[hidden] {
  display: none !important;
}

.scene-backdrop {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.38), rgba(255, 255, 255, 0.08) 28%, rgba(247, 237, 216, 0.16) 100%),
    url('./background_scene.webp?v=20260409a') center/cover no-repeat;
}

.surface--wood-dark {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(
      90deg,
      transparent 0 14px,
      rgba(47, 28, 17, 0.16) 14px 15px,
      transparent 15px 33px,
      rgba(255, 255, 255, 0.05) 33px 34px,
      transparent 34px 54px,
      rgba(26, 16, 10, 0.08) 54px 55px,
      transparent 55px 78px
    ),
    linear-gradient(180deg, #7b4f31 0%, #684029 58%, #58341f 100%);
}

.surface--wood-light {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.1), rgba(0, 0, 0, 0.05)),
    repeating-linear-gradient(
      90deg,
      transparent 0 16px,
      rgba(126, 75, 35, 0.11) 16px 17px,
      transparent 17px 36px,
      rgba(255, 255, 255, 0.08) 36px 37px,
      transparent 37px 58px,
      rgba(92, 58, 31, 0.07) 58px 59px,
      transparent 59px 82px
    ),
    linear-gradient(180deg, #d1a173 0%, #bf8a5c 56%, #aa744b 100%);
}

.surface--felt {
  background-image:
    radial-gradient(circle at 24% 22%, rgba(255, 255, 255, 0.14), transparent 22%),
    radial-gradient(circle at 76% 70%, rgba(214, 192, 160, 0.1), transparent 26%),
    repeating-linear-gradient(
      135deg,
      transparent 0 4px,
      rgba(255, 255, 255, 0.12) 4px 5px,
      transparent 5px 11px,
      rgba(208, 186, 154, 0.08) 11px 12px,
      transparent 12px 19px,
      rgba(157, 125, 91, 0.04) 19px 20px,
      transparent 20px 28px
    ),
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), rgba(255, 255, 255, 0) 30%),
    linear-gradient(180deg, var(--ui-felt-base) 0%, var(--ui-felt-deep) 100%);
}

.texture-scale--tight {
  background-size: 100% 100%, 132px 100%, 100% 100%;
}

.texture-scale--wide {
  background-size: 100% 100%, 236px 100%, 100% 100%;
}

.texture-tone--deep.surface--wood-dark {
  background-image:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.18)),
    repeating-linear-gradient(
      90deg,
      transparent 0 14px,
      rgba(47, 28, 17, 0.18) 14px 15px,
      transparent 15px 33px,
      rgba(255, 255, 255, 0.05) 33px 34px,
      transparent 34px 54px,
      rgba(26, 16, 10, 0.08) 54px 55px,
      transparent 55px 78px
    ),
    linear-gradient(180deg, #704629 0%, #5a3621 58%, #482a19 100%);
}

.app-shell {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100dvh;
  padding: calc(var(--safe-top) + 8px) calc(var(--safe-right) + 8px) calc(var(--safe-bottom) + 8px) calc(var(--safe-left) + 8px);
  gap: 10px;
  transition: filter 0.28s ease, opacity 0.28s ease;
}

body.is-starting .app-shell {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

body.is-modal-active .app-shell {
  filter: blur(3px) saturate(0.84);
  pointer-events: none;
}

.app-topbar {
  position: relative;
  z-index: 100;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  flex-shrink: 0;
}

.app-topbar__wood {
  border-radius: 0 0 24px 24px;
  padding: 4px 8px 8px;
  background-color: var(--ui-wood-dark);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.24);
}

.app-topbar__light {
  padding: 4px;
  border-radius: 0 0 20px 20px;
  background-color: var(--ui-wood-light);
}

.app-topbar__felt {
  display: grid;
  grid-template-columns: 38px minmax(0, 1.2fr) minmax(0, 0.8fr) 38px;
  align-items: center;
  gap: 8px;
  min-height: 46px;
  padding: 4px 6px 6px;
  border-radius: 0 0 16px 16px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.56), rgba(255, 255, 255, 0.1)),
    var(--ui-felt-base);
}

.identity-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.5);
}

.identity-chip__avatar {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
  border: 2px solid var(--color-primary);
  border-radius: 50%;
  overflow: hidden;
  background: #fff center/contain no-repeat;
}

.identity-chip__name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 13px;
  font-weight: 900;
}

.progress-chip {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 4px 8px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.05);
}

.progress-chip__value {
  white-space: nowrap;
  font-size: 12px;
  font-weight: 900;
}

.progress-chip__track {
  flex: 1;
  min-width: 30px;
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.1);
}

.progress-chip__fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #57b89b, var(--color-success));
  transition: width 0.4s ease;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.1);
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.icon-button--accent {
  color: #fff;
  background: linear-gradient(180deg, var(--color-accent), #f3722c);
}

.app-main {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 0;
  width: 100%;
}

.map-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 560px;
  min-height: 0;
}

.map-stage__frame-wrap {
  position: relative;
  width: min(100%, 540px);
  height: min(100%, 680px);
  aspect-ratio: 3 / 4.12;
}

.map-stage__frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 38px;
}

.map-stage__viewport {
  position: absolute;
  inset: 7.2%;
  z-index: 1;
  overflow: hidden;
  border-radius: 28px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.02)),
    #dfe5df;
  box-shadow: inset 0 0 0 1px rgba(76, 51, 33, 0.08);
}

.map-stage__notice {
  position: absolute;
  left: 5.5%;
  right: 5.5%;
  top: 8.5%;
  z-index: 4;
  height: 28px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  background: rgba(248, 243, 232, 0.42);
  backdrop-filter: blur(2px);
  box-shadow: 0 2px 8px rgba(54, 35, 20, 0.07);
}

.map-stage__notice-track {
  display: flex;
  align-items: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

.map-stage__notice-track span {
  display: inline-block;
  padding-left: 100%;
  white-space: nowrap;
  color: rgba(78, 50, 28, 0.84);
  font-size: 12px;
  font-weight: 700;
  animation: quest-marquee 18s linear infinite;
}

@keyframes quest-marquee {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

#map {
  width: 100%;
  height: 100%;
}

.leaflet-container {
  font-family: inherit;
  background: #dceaf6;
}

.leaflet-interactive {
  transition: fill-opacity 0.18s ease, stroke-width 0.18s ease, opacity 0.18s ease;
}

.map-stage__frame-image {
  position: absolute;
  inset: 0;
  z-index: 10;
  width: 100%;
  height: 100%;
  object-fit: fill;
  pointer-events: none;
}

.map-stage__dock {
  position: absolute;
  left: 50%;
  bottom: 5%;
  z-index: 20;
  transform: translateX(-50%);
}

.map-stage__dock-wood {
  padding: 4px;
  border-radius: 22px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
}

.map-stage__dock-light {
  position: relative;
  display: flex;
  gap: 6px;
  padding: 5px;
  border-radius: 18px;
}

.map-stage__dock-felt {
  position: absolute;
  inset: 4px;
  z-index: 0;
  border-radius: 14px;
}

.map-stage__dock-button {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 8px;
  border-radius: 12px;
  position: relative;
  z-index: 1;
  background: rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.map-stage__dock-button img {
  width: 20px;
  height: 20px;
  object-fit: contain;
}

.simple-user-marker {
  background: transparent;
  border: 0;
}

.user-location-dot {
  width: 20px;
  height: 20px;
  border: 3px solid #fff;
  border-radius: 999px;
  box-shadow:
    0 0 0 2px rgba(76, 51, 33, 0.2),
    0 10px 18px rgba(0, 0, 0, 0.22);
}

.deck-module {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  flex-shrink: 0;
}

.deck-module__wood {
  padding: 10px 0 12px;
  border-radius: 28px 28px 0 0;
  background-color: var(--ui-wood-dark);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.16);
}

.deck-module__tab-base {
  width: min(100%, 320px);
  margin: 0 auto;
  padding: 8px 8px 0;
  border-radius: 26px 26px 0 0;
}

.deck-module__tab-nav {
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: -10px;
}

.deck-module__tab {
  width: 76px;
  height: 70px;
}

.deck-module__tab-wood {
  display: flex;
  width: 100%;
  height: 100%;
  padding: 4px;
  border-radius: 18px 18px 10px 10px;
  box-shadow: 0 4px 0 rgba(123, 75, 43, 0.24);
}

.deck-module__tab.is-active {
  transform: translateY(-6px);
}

.deck-module__tab-face {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: 100%;
  height: 100%;
  padding: 6px 4px;
  border-radius: 14px 14px 8px 8px;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.08);
}

.deck-module__tab.is-active .deck-module__tab-wood {
  box-shadow: 0 8px 18px rgba(63, 124, 218, 0.18);
}

.deck-module__tab.is-active .deck-module__tab-face {
  border: 3px solid var(--color-primary);
}

.deck-module__tab-glyph {
  font-size: 18px;
  font-weight: 900;
  line-height: 1;
}

.deck-module__tab-label {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.deck-module__content-frame {
  margin: 8px 12px;
  padding: 6px;
  border-radius: 24px;
  background-color: var(--ui-wood-light);
}

.deck-module__content {
  min-height: 180px;
  max-height: 35vh;
  padding: 16px;
  overflow-y: auto;
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.32), rgba(255, 255, 255, 0.02)),
    var(--ui-felt-base);
}

.panel-header {
  margin-bottom: 14px;
}

.panel-header__title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 900;
}

.panel-header__subtitle {
  margin: 4px 0 0;
  color: var(--ui-ink-soft);
  font-size: 0.82rem;
  line-height: 1.4;
}

.panel-stack {
  display: grid;
  gap: 12px;
}

.panel-view {
  display: none;
}

.panel-view.is-active {
  display: grid;
  gap: 12px;
}

.accordion-list,
.activity-feed {
  display: grid;
  gap: 10px;
}

.accordion-item,
.activity-item,
.action-block,
.target-card,
.menu-section {
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  box-shadow: var(--ui-shadow-soft);
}

.accordion-item {
  overflow: hidden;
  background: rgba(255, 255, 255, 0.84);
}

.accordion-item__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 14px 16px;
  font-weight: 800;
  text-align: left;
}

.accordion-item__body {
  display: none;
  padding: 0 16px 15px;
  color: var(--ui-ink-soft);
  line-height: 1.5;
}

.accordion-item.is-open .accordion-item__body {
  display: block;
}

.accordion-item__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 36px;
  min-height: 28px;
  padding: 0 10px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 900;
}

.activity-item {
  display: grid;
  gap: 4px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.8);
}

.activity-item strong {
  font-size: 0.95rem;
}

.activity-item span,
.activity-item small {
  color: var(--ui-ink-soft);
}

.activity-item--empty,
.scenario-empty {
  padding: 16px;
  text-align: center;
  color: var(--ui-ink-soft);
  font-weight: 700;
  background: rgba(255, 255, 255, 0.62);
}

.action-block {
  display: grid;
  gap: 16px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.78);
}

.action-block__head p {
  margin: 0;
  line-height: 1.55;
  font-weight: 700;
}

.target-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.8);
}

.target-card__status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}

.target-card__note {
  color: var(--ui-ink-soft);
  font-size: 0.82rem;
  font-weight: 700;
}

.target-card h3,
.target-card p {
  margin: 0;
}

.target-card p {
  line-height: 1.55;
}

.target-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.target-chip {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 12px;
  border: 1px solid rgba(63, 124, 218, 0.24);
  border-radius: 999px;
  background: rgba(63, 124, 218, 0.12);
  font-size: 0.82rem;
  font-weight: 700;
}

.target-chip--empty {
  border-color: var(--ui-border);
  background: rgba(123, 75, 43, 0.08);
}

.state-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  color: #fff;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.state-badge--idle {
  background: linear-gradient(180deg, #9e8a73, #7f6a54);
}

.state-badge--ready {
  background: linear-gradient(180deg, #5aa3f3, #3f7cda);
}

.state-badge--warn {
  background: linear-gradient(180deg, #f2a44d, #d97719);
}

.state-badge--success {
  background: linear-gradient(180deg, #5ec6a5, #43aa8b);
}

.mission-flow {
  display: grid;
  gap: 10px;
}

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

.mission-step {
  display: grid;
  gap: 4px;
  padding: 10px;
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.64);
}

.mission-step__eyebrow {
  color: var(--ui-ink-soft);
  font-size: 0.68rem;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.mission-step__title {
  font-size: 0.84rem;
  font-weight: 900;
}

.mission-step__state {
  color: var(--ui-ink-soft);
  font-size: 0.72rem;
  font-weight: 800;
}

.mission-step--current {
  border-color: rgba(63, 124, 218, 0.4);
  background: rgba(63, 124, 218, 0.12);
  box-shadow: inset 0 0 0 1px rgba(63, 124, 218, 0.14);
}

.mission-step--locked {
  border-color: rgba(67, 170, 139, 0.3);
  background: rgba(67, 170, 139, 0.12);
}

.start-screen,
.game-modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--ui-overlay);
  backdrop-filter: blur(4px);
}

.start-screen {
  z-index: 20000;
}

.start-screen.is-hero {
  padding: clamp(18px, 2vw, 32px);
  background:
    radial-gradient(circle at top, rgba(255, 252, 243, 0.32), transparent 34%),
    repeating-linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.06) 0 7px,
      rgba(127, 150, 110, 0.04) 7px 15px,
      rgba(98, 74, 47, 0.04) 15px 23px
    ),
    linear-gradient(180deg, #ece3c7 0%, #b8c696 44%, #8ca06d 100%);
  backdrop-filter: none;
}

.game-modal {
  z-index: 22000;
}

body.is-modal-active .start-screen {
  pointer-events: none;
}

.start-card,
.modal-card {
  display: flex;
  flex-direction: column;
  width: min(100%, 460px);
  min-width: 0;
  max-width: 100%;
  max-height: min(88vh, 780px);
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 36px;
  box-shadow: var(--ui-shadow-strong);
}

.start-card {
  background: linear-gradient(180deg, rgba(123, 75, 43, 0.92), rgba(98, 61, 36, 0.92));
}

.start-card.is-hero-view {
  position: relative;
  width: min(calc(100vw - 48px), 1280px);
  height: min(calc(100dvh - 36px), 920px);
  overflow: visible;
  max-height: none;
  border: 0;
  border-radius: 0;
  background: none;
  box-shadow: none;
  backdrop-filter: none;
}

.start-card.is-hero-view::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0)),
    url('./background_scene.webp?v=20260409a') center center / auto 100% no-repeat;
  pointer-events: none;
}

.start-card.is-hero-view::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.09), transparent 26%),
    linear-gradient(90deg, rgba(236, 227, 199, 0) 0%, rgba(236, 227, 199, 0.12) 13%, rgba(236, 227, 199, 0) 24%, rgba(236, 227, 199, 0) 76%, rgba(101, 122, 82, 0.1) 87%, rgba(101, 122, 82, 0) 100%);
  pointer-events: none;
}

.modal-card {
  background: linear-gradient(180deg, rgba(123, 75, 43, 0.94), rgba(98, 61, 36, 0.94));
}

.start-card__inner,
.modal-card__inner {
  display: flex;
  flex: 1;
  min-width: 0;
  min-height: 0;
  padding: 8px;
}

.start-card__content,
.modal-card__content {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  border-radius: 30px;
  background: var(--ui-paper);
}

.start-card.is-hero-view .start-card__content {
  position: relative;
  z-index: 1;
  overflow: visible;
  border-radius: 0;
  background: transparent;
}

.start-card__hero {
  flex-shrink: 0;
  padding: 30px 20px 14px;
  text-align: center;
}

.start-card__logo {
  width: min(100%, 420px);
  margin: 0 auto 15px;
  filter: drop-shadow(0 8px 15px rgba(0, 0, 0, 0.15));
}

.start-card__welcome {
  max-width: 30rem;
  margin: 10px auto 0;
  color: #6d4f35;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.55;
}

.start-card__body,
.modal-card__body {
  flex: 1;
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 10px 24px 30px;
}

.start-view {
  display: grid;
  min-width: 0;
  gap: 14px;
}

.start-card.is-hero-view .start-card__inner,
.start-card.is-hero-view .start-card__content,
.start-card.is-hero-view .start-card__body {
  padding: 0;
}

.start-card.is-hero-view .start-card__hero {
  display: grid;
  justify-items: center;
  gap: 18px;
  padding: min(7.5vh, 64px) 0 0;
}

.start-card.is-hero-view .start-card__logo {
  width: min(100%, 520px);
  margin: 0;
  filter:
    drop-shadow(1px 1px 0 rgba(52, 30, 16, 0.94))
    drop-shadow(-1px 1px 0 rgba(52, 30, 16, 0.94))
    drop-shadow(1px -1px 0 rgba(52, 30, 16, 0.94))
    drop-shadow(-1px -1px 0 rgba(52, 30, 16, 0.94))
    drop-shadow(0 16px 38px rgba(0, 0, 0, 0.38));
}

.start-card.is-hero-view .start-card__welcome {
  max-width: 34rem;
  margin: 0;
  padding: 0 20px;
  color: #fff7e9;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.7;
  text-shadow:
    0 2px 10px rgba(0, 0, 0, 0.45),
    0 0 2px rgba(45, 24, 10, 0.82);
}

.start-card.is-hero-view #start-home-view {
  justify-items: center;
  width: min(100%, 460px);
  margin: auto auto 0;
  box-sizing: border-box;
  padding: 0 clamp(16px, 3vw, 24px) min(8vh, 68px);
}

.start-card__actions,
.modal-card__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  flex-shrink: 0;
  padding: 20px 24px;
  background: rgba(215, 192, 156, 0.78);
}

.hero-choice-grid {
  display: grid;
  width: 100%;
  grid-template-columns: 1fr;
  gap: 14px;
}

.hero-choice {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 18px 20px;
  border: 1px solid rgba(255, 245, 228, 0.24);
  border-radius: 20px;
  text-align: left;
  color: #fff9f0;
  background: rgba(33, 21, 12, 0.3);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 18px 34px rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(8px) saturate(1.03);
}

.hero-choice--primary {
  background:
    linear-gradient(180deg, rgba(85, 145, 235, 0.28), rgba(85, 145, 235, 0.08)),
    rgba(33, 21, 12, 0.34);
}

.hero-choice--secondary {
  background:
    linear-gradient(180deg, rgba(255, 159, 28, 0.26), rgba(255, 159, 28, 0.08)),
    rgba(33, 21, 12, 0.34);
}

.hero-choice__title {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.2;
}

.hero-choice__text {
  color: rgba(255, 248, 235, 0.88);
  font-size: 0.86rem;
  font-weight: 700;
  line-height: 1.5;
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.22);
}

.start-card.is-hero-view #btn-start-login {
  width: 100%;
  background: linear-gradient(180deg, rgba(85, 145, 235, 0.96), rgba(63, 124, 218, 0.94));
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.22),
    0 14px 28px rgba(34, 62, 110, 0.34);
}

.resume-intro {
  margin: 0;
  color: var(--ui-ink-soft);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.55;
}

.resume-list {
  display: grid;
  gap: 10px;
}

.resume-card {
  display: grid;
  gap: 8px;
  width: 100%;
  padding: 14px;
  border: 1px solid var(--ui-border);
  border-radius: 18px;
  text-align: left;
  color: var(--ui-ink);
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--ui-shadow-soft);
}

.resume-card.selected {
  border-color: rgba(63, 124, 218, 0.52);
  background: #f0f7ff;
  box-shadow:
    inset 0 0 0 2px rgba(63, 124, 218, 0.16),
    var(--ui-shadow-soft);
}

.resume-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.resume-card__stamp,
.resume-card__state,
.resume-card__meta,
.resume-card__progress {
  margin: 0;
}

.resume-card__stamp {
  color: var(--ui-ink-soft);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.resume-card__state {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 0 10px;
  border-radius: 999px;
  background: rgba(63, 124, 218, 0.12);
  color: var(--color-primary-dark);
  font-size: 0.7rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.resume-card__title {
  font-size: 0.96rem;
  font-weight: 900;
}

.resume-card__meta,
.resume-card__progress {
  color: var(--ui-ink-soft);
  font-size: 0.84rem;
  font-weight: 700;
  line-height: 1.5;
}

.scenario-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
}

.scenario-controls .cta-button {
  flex: 1 1 130px;
}

.menu-section {
  display: grid;
  min-width: 0;
  gap: 12px;
  padding: 14px;
  background: rgba(255, 255, 255, 0.58);
}

#scenario-selection {
  min-width: 0;
}

.menu-section + .menu-section {
  margin-top: 12px;
}

.menu-section__title {
  margin: 0;
  color: var(--ui-ink-soft);
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.menu-section__title span {
  display: inline-block;
  padding-bottom: 4px;
  border-bottom: 2px solid rgba(184, 122, 68, 0.44);
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.team-grid,
.scenario-stack {
  display: grid;
  gap: 10px;
}

.mode-item,
.team-item,
.scenario-item,
.avatar-item,
.modal-option-btn {
  border: 1px solid var(--ui-border);
  background: #fff;
}

.mode-item,
.modal-option-btn {
  min-height: 50px;
  border-radius: 14px;
  font-weight: 800;
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-soft);
}

.mode-item.selected,
.modal-option-btn.selected {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(180deg, var(--color-primary), var(--color-primary-dark));
  box-shadow: 0 10px 22px rgba(63, 124, 218, 0.28);
}

.team-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  text-align: left;
  font-weight: 800;
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-soft);
}

.team-item.selected {
  border-color: rgba(63, 124, 218, 0.55);
  background: #f0f7ff;
  box-shadow:
    inset 0 0 0 2px rgba(63, 124, 218, 0.18),
    var(--ui-shadow-soft);
}

.team-item__swatch {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  border-radius: 999px;
  box-shadow: 0 0 0 3px rgba(76, 51, 33, 0.08);
}

.scenario-item {
  display: grid;
  gap: 6px;
  width: 100%;
  padding: 13px 14px;
  border-radius: 16px;
  text-align: left;
  color: var(--ui-ink);
  box-shadow: var(--ui-shadow-soft);
}

.scenario-item.selected {
  border-color: rgba(63, 124, 218, 0.55);
  background: #f0f7ff;
  box-shadow:
    inset 0 0 0 2px rgba(63, 124, 218, 0.18),
    var(--ui-shadow-soft);
}

.scenario-item__title {
  font-size: 0.95rem;
  font-weight: 900;
}

.scenario-item__desc {
  color: var(--ui-ink-soft);
  font-size: 0.9rem;
  line-height: 1.45;
}

.scenario-item__meta {
  color: var(--ui-ink-soft);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.avatar-scroll-row {
  display: flex;
  flex-wrap: nowrap;
  gap: 10px;
  width: 100%;
  min-width: 0;
  max-width: 100%;
  padding: 10px 2px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
}

.avatar-scroll-row::-webkit-scrollbar {
  display: none;
}

.avatar-item {
  display: grid;
  gap: 6px;
  justify-items: center;
  min-height: 104px;
  flex: 0 0 90px;
  padding: 8px;
  border-radius: 14px;
  text-align: center;
  color: var(--ui-ink);
  scroll-snap-align: center;
  box-shadow: var(--ui-shadow-soft);
}

.avatar-item.selected {
  border-color: rgba(63, 124, 218, 0.55);
  background: #f0f7ff;
  box-shadow:
    inset 0 0 0 2px rgba(63, 124, 218, 0.18),
    var(--ui-shadow-soft);
}

.avatar-item__img-wrap {
  width: 44px;
  height: 44px;
}

.avatar-item__img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.avatar-item__name {
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.2;
}

.modal-card__header {
  padding: 22px 24px 0;
}

.modal-card__title {
  margin: 0;
  font-size: 1.12rem;
  font-weight: 900;
}

.modal-card__message {
  display: grid;
  gap: 12px;
  color: var(--ui-ink-soft);
  line-height: 1.55;
}

.modal-card__input {
  width: 100%;
  min-height: 50px;
  padding: 0 14px;
  border: 1px solid var(--ui-border);
  border-radius: 14px;
  background: #fff;
  color: var(--ui-ink);
}

.modal-card__options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.status-sheet,
.mission-sheet {
  display: grid;
  gap: 10px;
}

.status-sheet__section {
  display: grid;
  gap: 10px;
  padding: 12px 14px;
  border: 1px solid var(--ui-border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.84);
}

.status-sheet__title {
  margin: 0;
  color: var(--ui-ink-soft);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.status-sheet__note {
  color: var(--ui-ink-soft);
  font-size: 0.85rem;
  line-height: 1.5;
}

.status-sheet p,
.mission-sheet p {
  margin: 0;
}

.mission-sheet__prompt {
  color: var(--ui-ink-soft);
  font-size: 0.8rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.mission-sheet__question {
  color: var(--ui-ink);
  font-size: 1rem;
  font-weight: 800;
}

.mission-sheet__hint {
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(63, 124, 218, 0.08);
  color: var(--ui-ink-soft);
}

.mission-sheet__lv {
  align-self: flex-start;
  border: 1px solid var(--ui-line, rgba(0, 0, 0, 0.15));
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--ui-ink-soft);
}

.cta-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  width: 100%;
  padding: 0 16px;
  border-radius: 14px;
  background: linear-gradient(180deg, #9f7a54, #7b5637);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.15);
}

.cta-button--primary {
  background: linear-gradient(180deg, #5591eb, var(--color-primary));
}

.cta-button--success {
  background: linear-gradient(180deg, #5ec6a5, var(--color-success));
}

.cta-button--danger {
  background: linear-gradient(180deg, #ef8f77, var(--color-danger));
}

.cta-button:not(:disabled):hover,
.mode-item:hover,
.team-item:hover,
.scenario-item:hover,
.avatar-item:hover,
.modal-option-btn:hover,
.icon-button:hover,
.map-stage__dock-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.02);
}

.cta-button:not(:disabled):active,
.mode-item:active,
.team-item:active,
.scenario-item:active,
.avatar-item:active,
.modal-option-btn:active,
.icon-button:active,
.map-stage__dock-button:active {
  transform: translateY(1px);
}

@media (max-width: 900px) {
  .deck-module {
    max-width: none;
  }

  .deck-module__tab {
    width: 72px;
  }
}

@media (max-width: 700px) {
  .app-shell {
    gap: 6px;
  }

  .start-screen.is-hero {
    padding: 0;
    background: #7f9164;
  }

  .start-card.is-hero-view {
    width: 100vw;
    height: 100dvh;
  }

  .start-card.is-hero-view::before {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.02) 30%, rgba(27, 18, 9, 0.1) 100%),
      url('./background_scene.webp?v=20260409a') center center / cover no-repeat;
  }

  .start-card.is-hero-view::after {
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0) 18%),
      linear-gradient(180deg, rgba(22, 15, 8, 0) 66%, rgba(22, 15, 8, 0.12) 100%);
  }

  .app-topbar__wood {
    border-radius: 0 0 20px 20px;
  }

  .map-stage__frame-wrap {
    width: min(100%, 480px);
  }

  .deck-module__tab-nav {
    gap: 4px;
  }

  .deck-module__tab {
    width: min(23vw, 76px);
  }

  .deck-module__content {
    max-height: 38vh;
  }

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

  .hero-choice-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  body {
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100dvh;
    padding: var(--safe-top) 0 calc(var(--safe-bottom) + 4px) 0;
  }

  .app-main {
    flex: 0 0 auto;
    min-height: auto;
    align-items: flex-start;
  }

  .app-topbar__wood {
    border-radius: 0;
    padding: 4px 6px 6px;
  }

  .app-topbar__felt {
    grid-template-columns: 34px minmax(0, 1.25fr) minmax(0, 0.75fr) 34px;
    min-height: 42px;
  }

  .identity-chip__name {
    font-size: 12px;
  }

  .progress-chip {
    padding: 4px 7px;
  }

  .map-stage__frame-wrap {
    width: 100%;
    height: auto;
    aspect-ratio: 3 / 4.22;
  }

  .deck-module__wood {
    border-radius: 22px 22px 0 0;
  }

  .deck-module__content-frame {
    margin: 8px 8px 0;
  }

  .deck-module__content {
    min-height: 168px;
    max-height: 40vh;
    padding: 14px;
  }

  .start-screen,
  .game-modal {
    padding: 12px;
  }

  .start-screen.is-hero {
    padding: 0;
  }

  .start-card,
  .modal-card {
    max-height: 92vh;
    border-radius: 28px;
  }

  .start-card.is-hero-view {
    max-height: none;
    border-radius: 0;
  }

  .start-card__hero {
    padding: 24px 18px 12px;
  }

  .start-card__logo {
    width: min(100%, 320px);
    margin-bottom: 12px;
  }

  .start-card.is-hero-view #start-home-view {
    width: min(100%, 100%);
    padding-bottom: min(6vh, 44px);
  }

  .start-card.is-hero-view .start-card__logo {
    width: min(100%, 360px);
  }

  .start-card.is-hero-view .start-card__welcome {
    padding: 0 6px;
    font-size: 0.92rem;
  }

  .start-card__body,
  .modal-card__body {
    padding: 10px 16px 22px;
  }

  .start-card__actions,
  .modal-card__actions {
    padding: 16px;
  }

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

  .resume-card__head {
    align-items: flex-start;
    flex-direction: column;
  }

  .scenario-controls .cta-button {
    flex-basis: 100%;
  }

  .cta-button {
    min-height: 48px;
  }
}

.map-stage__fallback-list {
  overflow: auto;
  background: rgba(249, 242, 226, 0.96);
}

.map-fallback {
  min-height: 100%;
  padding: 18px;
  color: #3b2a1d;
  font-family: inherit;
}

.map-fallback__notice {
  margin: 0 0 12px;
  font-size: 0.86rem;
  font-weight: 800;
  color: #7a4a22;
}

.map-fallback__grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 8px;
}

.map-fallback__ward {
  min-height: 56px;
  padding: 9px 10px;
  border: 1px solid rgba(122, 74, 34, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  color: #352317;
  text-align: left;
  cursor: pointer;
}

.map-fallback__ward strong,
.map-fallback__ward span {
  display: block;
}

.map-fallback__ward strong {
  font-size: 0.86rem;
}

.map-fallback__ward span {
  margin-top: 2px;
  font-size: 0.72rem;
  color: #72513a;
}
