:root {
  --ink: #3f3d38;
  --pencil: rgba(44, 43, 40, 0.48);
  --soft-pencil: rgba(44, 43, 40, 0.18);
  --paper: #f8f5ec;
  --paper-warm: #fffaf0;
  --muted: #776f66;
  --green: #c7dac3;
  --path: #eadfbf;
  --water: #c9e3dd;
  --star: #f3dc83;
  --shadow: 0 18px 36px rgba(66, 58, 46, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(rgba(85, 80, 70, 0.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(85, 80, 70, 0.035) 1px, transparent 1px),
    #ece8dc;
  background-size: 28px 28px;
  font-family:
    "Hiragino Maru Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
}

button {
  font: inherit;
}

.game-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 22px 0 34px;
}

.hero,
.panel {
  position: relative;
  border: 2px solid var(--pencil);
  border-radius: 10px 7px 12px 8px;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.72), rgba(255, 249, 235, 0.88)),
    var(--paper);
  box-shadow: var(--shadow);
}

.hero::before,
.panel::before {
  content: "";
  position: absolute;
  inset: 7px;
  pointer-events: none;
  border: 1px dashed rgba(44, 43, 40, 0.2);
  border-radius: 8px 10px 7px 12px;
}

.hero {
  display: grid;
  grid-template-columns: minmax(260px, 0.7fr) minmax(340px, 1fr);
  gap: 18px;
  align-items: stretch;
  min-height: 410px;
  overflow: hidden;
}

.hero-copy {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: clamp(28px, 4vw, 54px);
}

.hero h1,
.section-heading h2 {
  margin: 0;
  line-height: 1.08;
}

.hero h1 {
  max-width: 8.6em;
  font-size: clamp(2.15rem, 4.8vw, 4.5rem);
  font-weight: 900;
}

.hero p:not(.eyebrow) {
  max-width: 30rem;
  margin: 18px 0 0;
  color: var(--muted);
  line-height: 1.9;
  font-weight: 800;
}

.hero-sketches {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  padding: 18px;
  background: rgba(255, 255, 255, 0.32);
}

.hero-sketches img {
  width: 100%;
  height: 100%;
  min-height: 178px;
  object-fit: cover;
  object-position: center;
  border: 2px solid rgba(44, 43, 40, 0.34);
  border-radius: 8px 12px 7px 10px;
  background: #f5f2e9;
  filter: saturate(0.9) contrast(0.94);
}

.eyebrow {
  margin: 0 0 8px;
  color: #687d61;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0;
  text-transform: uppercase;
}

.panel {
  margin-top: 18px;
}

.roster-panel,
.map-panel,
.party-panel,
.battle-panel,
.log-panel {
  padding: 18px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.section-heading h2 {
  font-size: clamp(1.35rem, 2vw, 2rem);
}

.section-heading.compact h2 {
  font-size: 1.3rem;
}

.primary-button,
.ghost-button,
.skill-buttons button,
.controls button {
  min-height: 44px;
  border: 2px solid var(--pencil);
  border-radius: 9px 6px 10px 7px;
  color: var(--ink);
  background: #fffdf7;
  cursor: pointer;
  font-weight: 900;
  transition: transform 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

.primary-button {
  padding: 0 22px;
  background: linear-gradient(180deg, #fff4bd, #efd47b);
  box-shadow: 0 6px 0 rgba(82, 77, 66, 0.18);
}

.ghost-button {
  padding: 0 16px;
}

button:hover {
  transform: translateY(-1px) rotate(-0.2deg);
  box-shadow: 0 5px 0 rgba(82, 77, 66, 0.12);
}

button:active {
  transform: translateY(1px);
  box-shadow: none;
}

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

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

.character-card {
  display: grid;
  gap: 12px;
  align-content: start;
  min-height: 100%;
  padding: 12px;
  border: 2px solid var(--soft-pencil);
  border-radius: 8px 11px 7px 10px;
  background: rgba(255, 253, 247, 0.86);
  cursor: pointer;
}

.character-card[aria-selected="true"] {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7), 0 0 0 8px color-mix(in srgb, var(--accent) 36%, transparent);
}

.character-card img {
  width: 100%;
  aspect-ratio: 1 / 1.05;
  border: 2px solid rgba(44, 43, 40, 0.28);
  border-radius: 8px 12px 7px 10px;
  background: #f4f0e6;
  object-fit: cover;
  object-position: center;
  filter: saturate(0.94) contrast(0.95);
}

.character-card h3 {
  display: grid;
  gap: 4px;
  margin: 0;
  font-size: 1.2rem;
}

.role {
  color: color-mix(in srgb, var(--accent) 68%, #3f3d38);
  font-size: 0.78rem;
}

.character-card p {
  margin: 0;
  min-height: 4.4em;
  color: var(--muted);
  line-height: 1.65;
  font-weight: 800;
}

.stats {
  display: grid;
  gap: 7px;
}

.stat-row {
  display: grid;
  grid-template-columns: 4.2em 1fr;
  gap: 8px;
  align-items: center;
  font-size: 0.85rem;
  font-weight: 900;
}

.mini-bar {
  height: 9px;
  overflow: hidden;
  border: 1px solid rgba(44, 43, 40, 0.18);
  border-radius: 999px;
  background: #e7e0cf;
}

.mini-bar span,
.bar span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--accent, #91ad8b);
  transition: width 220ms ease;
}

.play-area {
  display: grid;
  grid-template-columns: minmax(340px, 0.95fr) minmax(330px, 0.78fr);
  gap: 18px;
}

.day-chip,
.enemy-name {
  min-width: 112px;
  padding: 10px 12px;
  border: 2px solid var(--soft-pencil);
  border-radius: 999px;
  background: rgba(255, 253, 247, 0.9);
  text-align: center;
  font-weight: 900;
}

.map-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 6px;
  width: 100%;
  aspect-ratio: 1;
  padding: 8px;
  border: 2px solid rgba(44, 43, 40, 0.34);
  border-radius: 9px 7px 12px 8px;
  background: #d7d8bd;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  min-width: 0;
  border: 1px solid rgba(44, 43, 40, 0.18);
  border-radius: 7px 9px 6px 8px;
  background: rgba(255, 253, 247, 0.34);
  font-size: clamp(0.82rem, 1.8vw, 1.08rem);
  font-weight: 900;
}

.tile.path {
  background: var(--path);
}

.tile.water {
  background: var(--water);
}

.tile.flower {
  background: var(--green);
}

.tile.goal {
  background: var(--star);
}

.tile.visited::after {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px dashed rgba(255, 255, 255, 0.65);
  border-radius: 6px;
}

.player-token {
  position: absolute;
  z-index: 3;
  width: 78%;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  overflow: hidden;
  border: 3px solid var(--accent);
  border-radius: 50%;
  background-color: #f8f5ec;
  background-repeat: no-repeat;
  background-size: 235%;
  box-shadow: 0 5px 12px rgba(43, 36, 27, 0.2);
}

.controls {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.controls button {
  font-size: 1.35rem;
}

.side-stack {
  display: grid;
  gap: 18px;
}

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

.party-member {
  display: grid;
  grid-template-columns: 58px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 9px;
  border: 1px solid var(--soft-pencil);
  border-radius: 8px 10px 7px 11px;
  background: rgba(255, 253, 247, 0.82);
}

.avatar {
  width: 58px;
  height: 58px;
  border: 2px solid var(--accent);
  border-radius: 50%;
  background-color: #f8f5ec;
  background-repeat: no-repeat;
  background-size: 235%;
  filter: saturate(0.96) contrast(0.96);
}

.team-avatar {
  width: 58px;
  height: 58px;
}

.party-member h3,
.party-member p {
  margin: 0;
}

.party-member h3 {
  font-size: 1rem;
}

.party-member p {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.hp-wrap {
  display: grid;
  gap: 4px;
  min-width: 82px;
  font-size: 0.75rem;
  font-weight: 900;
}

.battle-stage {
  display: grid;
  grid-template-columns: 1fr minmax(150px, 0.8fr);
  gap: 14px;
  align-items: center;
}

.team-portraits {
  display: grid;
  grid-template-columns: repeat(4, 60px);
  gap: 8px;
  align-content: center;
}

.enemy-card {
  display: grid;
  gap: 10px;
  justify-items: center;
  padding: 14px;
  border: 1px solid var(--soft-pencil);
  border-radius: 8px 12px 7px 10px;
  background: rgba(255, 253, 247, 0.82);
}

.enemy-icon {
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  border: 2px solid var(--pencil);
  border-radius: 50%;
  color: #fffdf7;
  background: #6a6259;
  font-size: 1.75rem;
  font-weight: 900;
}

.bar {
  width: 100%;
  height: 12px;
  overflow: hidden;
  border: 1px solid rgba(44, 43, 40, 0.18);
  border-radius: 999px;
  background: #e7e0cf;
}

.enemy-card p {
  margin: 0;
  color: var(--muted);
  font-weight: 900;
}

.skill-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.skill-buttons button {
  padding: 10px;
  line-height: 1.35;
  background: rgba(255, 253, 247, 0.86);
}

.skill-buttons strong {
  display: block;
}

.skill-buttons span {
  display: block;
  color: var(--muted);
  font-size: 0.78rem;
}

.log-panel ol {
  display: grid;
  gap: 8px;
  max-height: 230px;
  margin: 0;
  padding-left: 24px;
  overflow: auto;
}

.log-panel li {
  padding: 8px 10px;
  border: 1px solid rgba(44, 43, 40, 0.1);
  border-radius: 8px 10px 7px 11px;
  background: rgba(255, 253, 247, 0.7);
  line-height: 1.55;
  font-weight: 800;
}

.victory {
  animation: pop 460ms ease;
}

@keyframes pop {
  0% {
    transform: scale(0.92);
  }
  70% {
    transform: scale(1.04);
  }
  100% {
    transform: scale(1);
  }
}

@media (max-width: 920px) {
  .hero,
  .play-area {
    grid-template-columns: 1fr;
  }

  .hero-sketches {
    min-height: 430px;
  }

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

@media (max-width: 580px) {
  .game-shell {
    width: min(100% - 18px, 1180px);
    padding-top: 10px;
  }

  .hero {
    min-height: unset;
  }

  .hero-copy {
    padding: 22px;
  }

  .hero-sketches {
    grid-template-columns: 1fr 1fr;
    min-height: 320px;
    padding: 10px;
  }

  .hero-sketches img {
    min-height: 145px;
  }

  .character-list,
  .skill-buttons,
  .battle-stage {
    grid-template-columns: 1fr;
  }

  .section-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .section-heading.compact {
    align-items: center;
    flex-direction: row;
  }

  .party-member {
    grid-template-columns: 58px 1fr;
  }

  .hp-wrap {
    grid-column: 1 / -1;
  }

  .team-portraits {
    grid-template-columns: repeat(4, minmax(44px, 58px));
  }
}
