:root {
  color-scheme: light;
  --ink: #37291c;
  --paper: #fff6df;
  --cream: #f9e8bd;
  --line: #3b2d1f;
  --red: #d85a4a;
  --blue: #4a7ab8;
  --green: #5c9a58;
  --yellow: #e8b847;
  --purple: #8768a7;
  --aqua: #4f9fa2;
  --shadow: rgba(69, 46, 24, 0.18);
  font-family:
    ui-rounded, "Apple SD Gothic Neo", "Noto Sans KR", system-ui, -apple-system,
    BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 16% 16%, rgba(255, 236, 173, 0.95), transparent 30%),
    radial-gradient(circle at 82% 24%, rgba(148, 208, 194, 0.55), transparent 26%),
    linear-gradient(135deg, #fff2cd 0%, #d8edda 52%, #f7d9bf 100%);
  color: var(--ink);
}

button {
  font: inherit;
  color: inherit;
}

.app-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.screen,
.battle-screen {
  position: relative;
  width: min(100vw - 24px, calc((100vh - 24px) * 16 / 9));
  height: min(100vh - 24px, calc((100vw - 24px) * 9 / 16));
  max-width: 1360px;
  max-height: 765px;
  min-width: 720px;
  min-height: 405px;
  border: 4px solid var(--line);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 24px 60px var(--shadow);
  overflow: hidden;
}

.screen {
  padding: 24px;
}

.is-hidden {
  display: none;
}

.page-bg {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(120, 193, 207, 0.35) 0 36%, transparent 37%),
    repeating-linear-gradient(-8deg, rgba(95, 150, 87, 0.12) 0 12px, transparent 12px 28px);
}

.page-bg::after {
  content: "";
  position: absolute;
  left: -5%;
  right: -5%;
  bottom: -10%;
  height: 36%;
  background: #a8d078;
  border-top: 4px solid var(--line);
  transform: rotate(-1.5deg);
}

.page {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 16px;
  height: 100%;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 50%;
  background: #ffe294;
  box-shadow: 0 5px 0 rgba(59, 45, 31, 0.15);
}

.brand h1,
.brand h2 {
  margin: 0;
  letter-spacing: 0;
  line-height: 1;
}

.brand h1 {
  font-size: clamp(32px, 4vw, 58px);
}

.brand h2 {
  font-size: clamp(26px, 3vw, 42px);
}

.subtitle {
  display: block;
  margin-top: 6px;
  color: #765a37;
  font-size: 15px;
  font-weight: 800;
}

.wallet {
  display: flex;
  gap: 8px;
  align-items: center;
  font-weight: 900;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 12px;
  border: 3px solid var(--line);
  border-radius: 999px;
  background: #fff8e9;
  box-shadow: 0 4px 0 rgba(59, 45, 31, 0.12);
}

.prop-icon {
  display: inline-block;
  width: var(--icon-size, 28px);
  height: var(--icon-size, 28px);
  flex: 0 0 auto;
  background-image: url("../assets/generated/props-sheet-alpha.png");
  background-repeat: no-repeat;
  background-size: 400% 200%;
  background-position: var(--prop-pos, 0% 0%);
  vertical-align: middle;
}

.icon-btn,
.primary-btn,
.secondary-btn {
  border: 3px solid var(--line);
  box-shadow: 0 5px 0 rgba(59, 45, 31, 0.16);
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.icon-btn:active,
.primary-btn:active,
.secondary-btn:active,
.card-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 rgba(59, 45, 31, 0.16);
}

.icon-btn {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #fff8e9;
  font-size: 22px;
  font-weight: 900;
}

.primary-btn,
.secondary-btn {
  min-height: 48px;
  padding: 0 18px;
  border-radius: 14px;
  font-weight: 950;
}

.primary-btn {
  background: #f06d56;
  color: #fffaf0;
}

.secondary-btn {
  background: #fff8e9;
}

.hero-layout {
  display: grid;
  grid-template-columns: 1.04fr 0.96fr;
  gap: 20px;
  align-items: stretch;
  min-height: 0;
}

.hero-stage {
  position: relative;
  border: 4px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #8ed2e0;
  box-shadow: inset 0 -18px 0 rgba(85, 57, 32, 0.08);
}

.hero-image,
.stage-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.hero-copy {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 14px;
  min-height: 0;
}

.hook {
  border: 4px solid var(--line);
  border-radius: 20px;
  background: #fff8e9;
  padding: 18px;
  box-shadow: 0 8px 0 rgba(59, 45, 31, 0.12);
}

.hook strong {
  display: block;
  font-size: clamp(24px, 3vw, 42px);
  line-height: 1.08;
}

.hook p {
  margin: 10px 0 0;
  color: #715235;
  font-size: 16px;
  font-weight: 800;
  line-height: 1.45;
}

.menu-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  min-height: 0;
}

.card-btn {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 112px;
  padding: 16px;
  border: 4px solid var(--line);
  border-radius: 18px;
  background: var(--card, #fff8e9);
  box-shadow: 0 7px 0 rgba(59, 45, 31, 0.14);
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

.card-icon {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: -6px 0 0 -5px;
  filter: drop-shadow(0 5px 0 rgba(59, 45, 31, 0.13));
}

.card-btn strong {
  font-size: 21px;
  line-height: 1.05;
}

.card-btn span {
  color: #765a37;
  font-weight: 800;
  line-height: 1.25;
}

.mode-grid,
.stage-grid,
.shop-grid {
  display: grid;
  gap: 14px;
  min-height: 0;
}

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

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

.mode-grid,
.stage-grid {
  align-items: start;
}

.shop-grid {
  grid-template-columns: repeat(4, 1fr);
  overflow: auto;
  padding-bottom: 10px;
}

.mode-card,
.stage-card,
.shop-card,
.team-panel {
  border: 4px solid var(--line);
  border-radius: 20px;
  background: #fff8e9;
  box-shadow: 0 7px 0 rgba(59, 45, 31, 0.14);
}

.mode-card,
.stage-card,
.shop-card {
  display: grid;
  align-content: start;
  min-height: 230px;
  padding: 16px;
  cursor: pointer;
  text-align: left;
}

.mode-card,
.stage-card {
  grid-template-rows: auto auto auto 1fr;
}

.mode-card.is-active,
.stage-card.is-active {
  outline: 6px solid rgba(232, 184, 71, 0.55);
  background: #fff1bd;
}

.mode-card b,
.stage-card b,
.shop-card b {
  display: block;
  margin-bottom: 8px;
  font-size: 22px;
}

.mode-title {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 8px;
}

.mode-title .portrait,
.mode-title .prop-icon {
  flex: 0 0 auto;
}

.mode-title b {
  margin-bottom: 0;
  line-height: 1.05;
}

.mini-preview {
  position: relative;
  height: 142px;
  margin-bottom: 14px;
  border: 3px dashed rgba(59, 45, 31, 0.35);
  border-radius: 15px;
  background: #94d4dd;
  overflow: hidden;
}

.mini-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.team-layout {
  display: grid;
  grid-template-columns: 1.08fr 0.92fr;
  gap: 16px;
  min-height: 0;
}

.team-panel {
  padding: 16px;
  overflow: hidden;
}

.slots {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 12px;
}

.slot,
.char-tile {
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff9ec;
}

.slot {
  min-height: 176px;
  padding: 10px;
  text-align: center;
}

.slot small {
  display: block;
  margin-bottom: 6px;
  color: #765a37;
  font-weight: 900;
}

.char-tile {
  display: grid;
  grid-template-columns: 50px 1fr;
  gap: 8px;
  align-items: center;
  width: 100%;
  min-height: 66px;
  padding: 7px 9px;
  cursor: pointer;
  text-align: left;
}

.char-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
  overflow: auto;
  max-height: 420px;
  padding-right: 4px;
}

.portrait {
  position: relative;
  width: 58px;
  height: 58px;
}

.sprite-portrait {
  width: 100%;
  height: 100%;
  border-radius: 18px;
  background-image: url("../assets/generated/characters-sheet-alpha.png");
  background-repeat: no-repeat;
  background-size: 400% 200%;
  background-position: var(--sprite-pos, 0% 0%);
  filter: drop-shadow(0 5px 0 rgba(59, 45, 31, 0.13));
}

.char-name {
  display: block;
  font-size: 17px;
  font-weight: 950;
}

.role {
  display: inline-flex;
  margin-top: 5px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #f2e0b5;
  color: #684b2d;
  font-size: 12px;
  font-weight: 900;
}

.shop-card .price {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.prep-layout {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
  min-height: 0;
}

.battle-map-preview {
  position: relative;
  min-height: 0;
  border: 4px solid var(--line);
  border-radius: 22px;
  overflow: hidden;
  background: #88d1df;
}

.control-sheet {
  display: grid;
  gap: 12px;
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 16px;
  background: #fff8e9;
  font-weight: 900;
}

.kbd {
  display: inline-grid;
  min-width: 44px;
  height: 38px;
  place-items: center;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(59, 45, 31, 0.12);
}

.result-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
  min-height: 0;
}

.result-visual,
.reward-panel {
  border: 4px solid var(--line);
  border-radius: 22px;
  background: #fff8e9;
  padding: 18px;
  box-shadow: 0 7px 0 rgba(59, 45, 31, 0.14);
}

.result-visual {
  display: grid;
  place-items: center;
  text-align: center;
}

.result-visual .big {
  display: block;
  font-size: clamp(42px, 7vw, 84px);
  line-height: 1;
}

.reward-panel {
  display: grid;
  align-content: center;
  gap: 12px;
}

.reward-line {
  display: flex;
  justify-content: space-between;
  padding: 14px;
  border: 3px solid var(--line);
  border-radius: 14px;
  background: #fff;
  font-weight: 950;
}

#game-canvas {
  width: 100%;
  height: 100%;
  display: block;
  background: #8ed2e0;
}

.battle-touch {
  position: absolute;
  inset: auto 22px 18px 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  pointer-events: none;
}

.stick,
.round-action,
.pause-btn {
  pointer-events: auto;
  border: 4px solid var(--line);
  box-shadow: 0 6px 0 rgba(59, 45, 31, 0.2);
}

.stick {
  width: 118px;
  height: 118px;
  border-radius: 50%;
  background: rgba(255, 248, 233, 0.78);
  display: grid;
  place-items: center;
  touch-action: none;
}

.stick span {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 3px solid var(--line);
  background: #f06d56;
}

.touch-actions {
  display: flex;
  gap: 14px;
}

.round-action {
  width: 92px;
  height: 92px;
  border-radius: 50%;
  color: #fffaf0;
  font-weight: 950;
  cursor: pointer;
}

.round-action.attack {
  background: #d85a4a;
}

.round-action.throw {
  background: #4a7ab8;
}

.pause-btn {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255, 248, 233, 0.9);
  font-weight: 950;
  cursor: pointer;
}

.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 20;
  place-items: center;
  align-content: center;
  gap: 10px;
  padding: 26px;
  text-align: center;
  background: var(--paper);
}

.rotate-hint strong {
  font-size: 26px;
}

.rotate-hint span {
  font-weight: 800;
  color: #765a37;
}

@media (orientation: portrait) and (max-width: 820px) {
  .rotate-hint {
    display: grid;
  }
}

@media (max-width: 900px) {
  .app-shell {
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right))
      max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
  }

  .screen,
  .battle-screen {
    width: min(100vw - 8px, calc((100vh - 8px) * 16 / 9));
    height: min(100vh - 8px, calc((100vw - 8px) * 9 / 16));
    min-width: 0;
    min-height: 0;
    border-width: 3px;
    border-radius: 18px;
  }

  .screen {
    padding: 10px;
  }

  .page {
    gap: 8px;
  }

  .brand {
    gap: 8px;
  }

  .brand-mark {
    width: 42px;
    height: 42px;
    font-size: 22px;
    border-width: 3px;
  }

  .brand h1 {
    font-size: 28px;
  }

  .brand h2 {
    font-size: 25px;
  }

  .wallet {
    gap: 5px;
  }

  .chip {
    padding: 5px 8px;
    border-width: 2px;
    font-size: 14px;
  }

  .hero-layout,
  .team-layout,
  .prep-layout,
  .result-layout {
    gap: 10px;
  }

  .hook {
    padding: 10px;
    border-width: 3px;
    border-radius: 16px;
  }

  .hook strong {
    font-size: 21px;
  }

  .hero-copy .hook p {
    display: none;
  }

  .menu-grid {
    gap: 8px;
  }

  .card-btn {
    min-height: 58px;
    padding: 8px 10px;
    border-width: 3px;
    border-radius: 14px;
  }

  .card-icon {
    width: 34px;
    height: 34px;
    margin: -4px 0 -1px -4px;
  }

  .card-btn strong {
    font-size: 15px;
  }

  .card-btn > span:not(.card-icon) {
    display: none;
  }

  .primary-btn,
  .secondary-btn {
    min-height: 36px;
    padding: 0 12px;
    border-width: 3px;
    border-radius: 12px;
    font-size: 14px;
  }

  .subtitle,
  .card-btn span,
  .mode-card span,
  .stage-card span {
    font-size: 12px;
  }

  .mode-card,
  .stage-card {
    min-height: 170px;
    padding: 10px;
  }

  .mini-preview {
    height: 84px;
    margin-bottom: 8px;
  }

  .mode-card b,
  .stage-card b {
    font-size: 16px;
  }

  .round-action {
    width: 74px;
    height: 74px;
  }

  .stick {
    width: 94px;
    height: 94px;
  }
}
