* {
  box-sizing: border-box;
}

:root {
  color-scheme: light;
  --ink: #4a3424;
  --cream: #fffaf0;
  --paper: rgba(255, 255, 255, 0.88);
  --accent: #e86b43;
  --accent-dark: #bd4328;
  --shadow: 0 18px 45px rgba(90, 58, 22, 0.22);
}

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

body {
  min-height: 100vh;
  font-family:
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    system-ui,
    sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 15%, rgba(255,255,255,.85), transparent 28%),
    radial-gradient(circle at 80% 20%, rgba(255,231,163,.78), transparent 30%),
    linear-gradient(135deg, #ffe9a8 0%, #f8ca79 48%, #f2aa63 100%);
  padding: 20px;
}

button {
  font: inherit;
}

.app {
  width: min(1050px, 100%);
  margin: 0 auto;
}

.game-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.25em;
  color: var(--accent-dark);
}

h1 {
  margin: 0;
  font-size: clamp(1.65rem, 4vw, 2.8rem);
  line-height: 1.1;
}

.score-panel {
  display: flex;
  gap: 10px;
}

.score-box {
  min-width: 102px;
  padding: 9px 14px;
  border: 2px solid rgba(91, 52, 20, 0.15);
  border-radius: 18px;
  background: var(--paper);
  box-shadow: 0 7px 16px rgba(80, 49, 17, 0.13);
  text-align: center;
}

.score-box span {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.72;
}

.score-box strong {
  display: block;
  font-size: 1.55rem;
  line-height: 1.1;
}

.game-layout {
  display: grid;
  grid-template-columns: 220px minmax(0, 480px);
  justify-content: center;
  align-items: start;
  gap: 18px;
}

.side-panel {
  display: grid;
  gap: 14px;
}

.panel-card {
  border: 2px solid rgba(91, 52, 20, 0.14);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-card h2 {
  margin: 0;
  padding: 12px 16px 8px;
  font-size: 1rem;
}

.next-card {
  text-align: center;
}

#nextCanvas {
  display: block;
  width: 150px;
  height: 150px;
  margin: 0 auto 12px;
}

.guide-card {
  padding-bottom: 12px;
}

.guide-card p {
  margin: 8px 16px;
  font-size: 0.88rem;
  line-height: 1.65;
}

.restart-button,
.game-over-card button {
  width: 100%;
  border: 0;
  border-bottom: 5px solid var(--accent-dark);
  border-radius: 18px;
  padding: 13px 16px 11px;
  color: #fff;
  background: linear-gradient(#ef805d, var(--accent));
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 9px 20px rgba(129, 52, 28, 0.22);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.restart-button:hover,
.game-over-card button:hover {
  filter: brightness(1.05);
}

.restart-button:active,
.game-over-card button:active {
  transform: translateY(3px);
  border-bottom-width: 2px;
}

.game-card {
  position: relative;
  width: 100%;
  border-radius: 28px;
  background: rgba(255, 255, 255, 0.28);
  box-shadow: var(--shadow);
  overflow: hidden;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 2 / 3;
  touch-action: none;
}

.game-over-panel {
  z-index: 20;
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(55, 28, 12, 0.56);
  backdrop-filter: blur(5px);
}

.game-over-panel.hidden {
  display: none;
}

.game-over-card {
  width: min(320px, 100%);
  padding: 28px;
  border: 4px solid #fff1cf;
  border-radius: 26px;
  background: #fffaf0;
  text-align: center;
  box-shadow: 0 24px 50px rgba(36, 14, 4, 0.34);
  animation: pop 0.24s ease-out;
}

.game-over-label {
  margin: 0;
  color: var(--accent-dark);
  font-weight: 900;
  letter-spacing: 0.18em;
}

.game-over-card h2 {
  margin: 7px 0 14px;
  font-size: 2rem;
}

.game-over-card p {
  margin: 0 0 20px;
}

footer {
  text-align: center;
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.78;
}

@keyframes pop {
  from {
    transform: scale(0.82);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 780px) {
  body {
    padding: 10px;
  }

  .game-header {
    align-items: center;
  }

  .score-box {
    min-width: 78px;
    padding: 7px 9px;
  }

  .score-box strong {
    font-size: 1.25rem;
  }

  .game-layout {
    grid-template-columns: minmax(0, 480px);
  }

  .side-panel {
    grid-template-columns: 1fr 1fr;
    order: 2;
  }

  .guide-card {
    display: none;
  }

  .restart-button {
    min-height: 62px;
    align-self: stretch;
  }

  .next-card {
    min-height: 62px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  .next-card h2 {
    padding: 0;
  }

  #nextCanvas {
    width: 58px;
    height: 58px;
    margin: 0;
  }

  footer {
    margin-top: 8px;
  }
}
