/* ===== BASE ===== */
*, *::before, *::after { box-sizing: border-box; }

body {
  font-family: 'Georgia', serif;
  background-color: #fffdf7;
  background-image: url('https://www.transparenttextures.com/patterns/white-diamond.png');
  margin: 0;
  padding: 1.5rem 1rem 3rem;
  text-align: center;
  color: #6e4b33;
}

h1 { color: #a67c52; font-size: 1.8rem; margin: 0.5rem 0 0.3rem; }

/* ===== LOGO ===== */
.home-logo { position: fixed; top: 20px; left: 20px; z-index: 1000; }
.home-logo img {
  width: 110px; height: auto;
  filter: drop-shadow(2px 2px 5px rgba(0,0,0,0.2));
  border-radius: 10px;
}

/* ===== NAV ===== */
.nav-row { margin-bottom: 0.8rem; }
.nav-button {
  display: inline-block; font-size: 0.85rem; padding: 5px 13px; margin: 0 4px;
  border: 2px solid #e0cfcf; border-radius: 12px; background: #fffafc;
  color: #333; text-decoration: none; cursor: pointer;
  font-family: 'Georgia', serif;
  box-shadow: 1px 1px 4px rgba(0,0,0,0.1); transition: background 0.2s;
}
.nav-button:hover { background: #ffe8cc; }

/* ===== HUD ===== */
.hud-bar {
  display: flex; justify-content: center; gap: 8px;
  flex-wrap: wrap; margin-bottom: 0.7rem;
}
.hud-pill {
  background: #fff7ee; border: 1.5px solid #e8d5c0;
  border-radius: 99px; padding: 4px 13px;
  font-size: 0.85rem; color: #8a6040;
  transition: color 0.3s;
}

/* ===== CANVAS WRAPPER ===== */
.canvas-wrap {
  position: relative;
  display: inline-block;
  line-height: 0;
}

#gameCanvas {
  display: block;
  width: min(480px, calc(100vw - 32px));
  height: auto;
  aspect-ratio: 480 / 560;
  border-radius: 16px;
  border: 3px solid #e8d5c0;
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  cursor: none;
}

/* ===== OVERLAYS ===== */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,245,225,0.97);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  border-radius: 14px;
  z-index: 10;
  overflow-y: auto;
  padding: 12px 8px;
}

.overlay-card {
  background: #fffdf7;
  border: 2px solid #e8d5c0;
  border-radius: 20px;
  padding: 1.4rem 1.8rem;
  max-width: 320px;
  width: 92%;
  text-align: center;
  flex-shrink: 0;
}

.overlay-title {
  font-size: 1.5rem;
  color: #a67c52;
  margin: 0 0 0.5rem;
  line-height: 1.3;
}
.overlay-sub {
  font-size: 0.88rem;
  color: #c4956a;
  margin: 0 0 1rem;
  font-style: italic;
  line-height: 1.4;
}

/* Legend */
.legend { text-align: left; margin: 0.3rem 0 0.9rem; }
.legend-row {
  display: flex; gap: 10px; align-items: center;
  font-size: 0.82rem; color: #7a5a3a; padding: 4px 0;
  line-height: 1.3;
}
.legend-row span:first-child { font-size: 1.05rem; width: 26px; text-align: center; }
.legend-row.bad   { color: #aa3333; }
.legend-row.bonus { color: #9a7000; }

.overlay-hint {
  font-size: 0.76rem; color: #b09070;
  margin-bottom: 0.9rem; font-style: italic;
}
.overlay-hi {
  font-size: 0.82rem; color: #b09070; margin-top: 0.7rem;
}

/* ===== BIG BUTTON ===== */
.big-btn {
  background: linear-gradient(135deg, #ffe8cc, #ffd0a8);
  border: 2px solid #d4a97a; border-radius: 14px;
  padding: 10px 24px; font-family: 'Georgia', serif;
  font-size: 1rem; color: #6e4020; cursor: pointer;
  font-weight: bold; display: block; width: 100%;
  transition: transform 0.15s, box-shadow 0.15s;
}
.big-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 14px rgba(212,169,122,0.4);
}

/* ===== GAME OVER STATS ===== */
.go-stats {
  display: flex; justify-content: center; gap: 18px;
  margin: 0.8rem 0;
}
.go-stats div { display: flex; flex-direction: column; gap: 3px; }
.go-stats span  { font-size: 0.72rem; color: #b09070; }
.go-stats strong{ font-size: 1.2rem; color: #7a5030; }
.go-msg {
  font-style: italic; color: #b07050;
  font-size: 0.88rem; margin-bottom: 1rem;
  min-height: 1.2em;
}

/* ===== FOOTER ===== */
.page-footer { margin-top: 1.2rem; font-size: 0.85rem; color: #a67c52; }

/* ===== MOBILE ===== */
@media (max-width: 500px) {
  h1 { font-size: 1.4rem; }
  .hud-bar { gap: 5px; }
  .hud-pill { font-size: 0.75rem; padding: 3px 9px; }
  .overlay-card { padding: 1.4rem 1.2rem; }
}
