:root {
  --paper: #fdf6e3;
  --paper-warm: #f4e7c8;
  --ink: #2c1810;
  --ink-soft: #5a3520;
  --accent: #d97757;
  --accent-soft: #f5a25b;
  --gauge-bg: #f0e4c8;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body { height: 100%; }

body {
  font-family: 'Noto Sans JP', sans-serif;
  background: radial-gradient(ellipse at top, #fdf6e3, #f0e4c8 70%, #e8d8b0 100%);
  color: var(--ink);
  overflow: hidden;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  transition: background 1.2s ease;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  padding: 14px 16px 18px;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto;
  position: relative;
}

.title-bar {
  text-align: center;
  flex: 0 0 auto;
}
.title {
  font-family: 'Kaisei Decol', serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: var(--ink);
}
.subtitle {
  font-size: 11px;
  color: var(--accent);
  margin-top: 2px;
  letter-spacing: 0.18em;
  font-weight: 500;
}
.stage-name {
  font-family: 'Kaisei Decol', serif;
  font-size: 13px;
  color: var(--ink-soft);
  margin-top: 4px;
  letter-spacing: 0.12em;
  font-weight: 500;
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  min-height: 0;
}

#game-canvas {
  width: 100%;
  max-width: 520px;
  aspect-ratio: 1;
  height: auto;
  border-radius: 16px;
  background: transparent;
  display: block;
}

.hud {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 16px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 2px 12px rgba(44, 24, 16, 0.08);
}

.gauge {
  display: flex;
  align-items: center;
  gap: 12px;
}
.gauge-label {
  font-weight: 700;
  font-size: 13px;
  color: var(--accent);
  width: 18px;
  text-align: center;
}
.gauge-bar {
  flex: 1;
  height: 10px;
  background: var(--gauge-bg);
  border-radius: 5px;
  overflow: hidden;
}
.gauge-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(to right, var(--accent), var(--accent-soft));
  border-radius: 5px;
  transition: width 0.25s ease;
}

.status {
  font-size: 12px;
  color: var(--ink-soft);
  text-align: center;
  letter-spacing: 0.05em;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(44, 24, 16, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  backdrop-filter: blur(2px);
}
.overlay.hidden { display: none; }
.overlay-card {
  background: white;
  padding: 28px 28px 24px;
  border-radius: 20px;
  text-align: center;
  min-width: 260px;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
  animation: pop 0.3s ease-out;
}
@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.overlay-card h2 {
  font-family: 'Kaisei Decol', serif;
  font-size: 22px;
  margin-bottom: 10px;
  color: var(--ink);
}
.overlay-card p {
  margin-bottom: 20px;
  color: var(--ink-soft);
  font-size: 14px;
}
.btn {
  background: var(--accent);
  color: white;
  border: none;
  padding: 11px 28px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: transform 0.1s, background 0.15s;
  letter-spacing: 0.05em;
}
.btn:hover { background: var(--accent-soft); }
.btn:active { transform: scale(0.96); }
