:root {
  color-scheme: light;
  --paper: #f4ead2;
  --paper-deep: #e8d8b0;
  --ink: #15212b;
  --ink-soft: #31465a;
  --accent: #9b3a24;
  --gold: #ae7b23;
  --shadow: rgba(31, 22, 15, 0.16);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background:
    radial-gradient(circle at top, rgba(255, 247, 222, 0.65), transparent 30%),
    linear-gradient(180deg, #ccb78d 0%, #9e7d52 100%);
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  touch-action: none;
  user-select: none;
}

body {
  display: flex;
}

.shell {
  flex: 1;
  display: flex;
  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));
}

.stage {
  position: relative;
  flex: 1;
  min-width: 0;
  min-height: 0;
  border-radius: 24px;
  overflow: hidden;
  box-shadow:
    inset 0 0 0 1px rgba(72, 49, 25, 0.22),
    0 24px 60px rgba(47, 28, 12, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 252, 238, 0.5), rgba(255, 240, 196, 0.15)),
    var(--paper);
}

#game {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.corner {
  position: absolute;
  max-width: min(38ch, 45vw);
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(247, 239, 217, 0.78);
  box-shadow: 0 6px 18px rgba(82, 54, 25, 0.12);
  backdrop-filter: blur(2px);
}

.corner.left {
  top: 14px;
  left: 14px;
}

.corner.right {
  top: 14px;
  right: 14px;
  text-align: right;
}

h1,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1rem, 2.4vw, 1.45rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

#subtitle,
#pageLabel,
#statusLine {
  font-size: clamp(0.85rem, 1.8vw, 1rem);
  line-height: 1.3;
}

#subtitle {
  margin-top: 0.35rem;
  color: var(--ink-soft);
}

#statusLine {
  margin-top: 0.2rem;
  color: var(--accent);
}

#replay {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  color: #f7ead4;
  background: linear-gradient(180deg, #714227, #4d2a17);
  box-shadow: 0 8px 18px rgba(59, 28, 12, 0.26);
  font: inherit;
  font-size: 1rem;
  pointer-events: auto;
}

#replay[hidden] {
  display: none;
}

@media (max-width: 720px), (max-height: 520px) {
  .corner {
    max-width: min(32ch, calc(100vw - 36px));
    padding: 10px 12px;
    border-radius: 12px;
  }

  .corner.right {
    top: auto;
    right: 10px;
    bottom: 10px;
    text-align: left;
  }

  .corner.left {
    top: 10px;
    left: 10px;
  }

  #replay {
    bottom: 78px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .stage,
  .corner,
  #replay {
    transition: none !important;
  }
}
