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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: #0e1120;
  color: #f0f0f0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

#app {
  width: 100%;
  height: 100%;
  position: relative;
}

#game-container {
  width: 100%;
  height: 100%;
}

/* ============================================================
   TYPOGRAPHY REFRESH — Bricolage Grotesque (display) & DM Sans (text)
   Only font-family / font-weight / numeric-variant overrides added.
   Sizes, colors, spacing, layout, and game rules are unchanged.
   ============================================================ */
body {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
}

/* Headings, title, subtitle & opponent names */
.game-title,
.game-subtitle,
.greeting-content h2,
.result-content h2,
.howtoplay-title,
.credits-title,
.still-ahead-title,
.stillahead-name {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 700;
}

/* Buttons & navigation labels */
.btn-primary,
.btn-secondary,
.btn-small,
.diff-button,
.btn-pit-action,
.btn-number,
.sound-toggle-btn {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 500;
}

/* Numbers & counters — tabular figures so values never shift */
.tile-value,
.store-count,
.target-info,
.total-seeds,
.opponent-progress,
.btn-number {
  font-family: 'Bricolage Grotesque', system-ui, sans-serif;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
}

/* Body copy: proverbs, instructions, taunts, titles, descriptions */
.proverb,
.proverb-translation,
.result-taunt,
.result-proverb,
.opponent-title,
.stillahead-title-text,
.stillahead-sub,
.howtoplay-text,
.credits-line,
.tile-label,
.store-label {
  font-family: 'DM Sans', system-ui, sans-serif;
  font-weight: 400;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

/* START SCREEN */
.screen-start {
  background: linear-gradient(to bottom, rgba(14, 17, 32, 0.3) 0%, rgba(14, 17, 32, 0.6) 50%, rgba(14, 17, 32, 0.95) 100%);
}

#start-bg-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  filter: brightness(0.35);
  z-index: -1;
}

.start-content {
  text-align: center;
  z-index: 1;
}

.difficulty-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1rem;
}

.difficulty-stack .btn-primary {
  min-width: 260px;
}

.diff-button {
  display: inline-block;
  white-space: nowrap;
  font-size: 1rem;
  text-align: center;
  line-height: 1.2;
}

/* SOUND TOGGLE BUTTON — normal document flow, centered at bottom of each screen */
.sound-toggle-btn {
  margin: 1rem auto 0 auto;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.5);
  background: rgba(14, 17, 32, 0.7);
  color: #ffd700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  backdrop-filter: blur(4px);
}

.sound-toggle-btn:hover {
  background: rgba(255, 215, 0, 0.18);
  border-color: #ffd700;
}

.sound-toggle-btn:active {
  transform: scale(0.92);
}

.game-title {
  font-size: 3.5rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  margin-bottom: 0.5rem;
  background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.game-subtitle {
  font-size: 1.1rem;
  color: #b0b0b0;
  margin-bottom: 3rem;
  letter-spacing: 0.05em;
}

/* GREETING SCREEN */
.screen-greeting {
  background: rgba(14, 17, 32, 0.95);
  justify-content: flex-start;
}

.portrait-banner {
  width: 100%;
  max-height: 34vh;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  object-position: center;
  border-radius: 12px;
  display: block;
  margin-bottom: 1.25rem;
}

.greeting-content {
  text-align: center;
  padding: 0 2rem;
}

.greeting-content h2 {
  font-size: 2.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: #ffd700;
}

.proverb {
  font-size: 1.15rem;
  font-style: italic;
  color: #d0d0d0;
  margin-bottom: 3rem;
  line-height: 1.6;
  max-width: 500px;
}

/* RESULT SCREEN */
.screen-result {
  background: rgba(14, 17, 32, 0.95);
  justify-content: flex-start;
}

.result-content {
  text-align: center;
  padding: 0 2rem;
}

.result-content h2 {
  font-size: 3rem;
  font-weight: 900;
  margin-bottom: 2rem;
  letter-spacing: 0.1em;
}

.result-content h2.victory {
  color: #4ade80;
  text-shadow: 0 0 20px rgba(74, 222, 128, 0.5);
}

.result-content h2.defeat {
  color: #f87171;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.5);
}

/* BUTTONS */
.btn-primary,
.btn-secondary {
  display: inline-block;
  padding: 1rem 3rem;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  text-transform: uppercase;
}

.btn-primary {
  background: linear-gradient(135deg, #ffd700 0%, #ff8c00 100%);
  color: #0e1120;
  box-shadow: 0 4px 20px rgba(255, 215, 0, 0.4);
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 30px rgba(255, 215, 0, 0.6);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  color: #f0f0f0;
  border: 2px solid rgba(255, 255, 255, 0.2);
  margin-top: 1rem;
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
}

/* PLAYING SCREEN */
.screen-playing {
  background: rgba(14, 17, 32, 0.97);
  justify-content: flex-start;
  padding-top: 0.75rem;
  gap: 0.4rem;
}

/* Greeting extras */
.opponent-progress {
  font-size: 0.85rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #a0a8c0;
  margin-bottom: 0.4rem;
}

.opponent-title {
  font-size: 1rem;
  font-style: italic;
  color: #fbbf24;
  margin-bottom: 0.75rem;
}

/* Result extras */
.result-taunt {
  font-size: 1.1rem;
  font-style: italic;
  color: #f0f0f0;
  margin-bottom: 1rem;
}

.result-proverb {
  font-size: 1rem;
  color: #d0d0d0;
  line-height: 1.6;
  margin-bottom: 1.5rem;
  max-width: 500px;
}

.proverb-translation {
  font-size: 0.85rem;
  color: #a0a8c0;
}

/* Board info tiles (YOUR STORE / COMPUTER / TARGET / LAST CAPTURE) */
.board-tiles {
  display: flex;
  gap: 6px;
  width: 100%;
  max-width: 340px;
  justify-content: center;
}

.board-tile {
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.3rem 0.2rem;
  border-radius: 8px;
  background: #181d36;
  border: 1px solid #283056;
}

.tile-label {
  font-size: 0.55rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #a0a8c0;
  text-align: center;
}

.tile-value {
  font-size: 1.15rem;
  font-weight: 900;
  color: #f0f0f0;
}

.tile-your-store { border-color: #10b981; }
.tile-your-store .tile-value { color: #10b981; }
.tile-computer { border-color: #a855f7; }
.tile-computer .tile-value { color: #a855f7; }
.tile-target { border-color: #ffd700; }
.tile-target .tile-value { color: #ffd700; }
.tile-last-capture { border-color: #38bdf8; }
.tile-last-capture .tile-value { color: #38bdf8; }

.board-hud {
  width: 100%;
  max-width: 360px;
  text-align: center;
  margin-bottom: 0.5rem;
}

.hud-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 1rem;
}

.hud-label {
  font-weight: 700;
  color: #ffd700;
  font-size: 0.95rem;
}

.hud-score {
  font-size: 0.9rem;
  color: #b0b0b0;
}

.hud-message {
  font-size: 0.85rem;
  color: #a0a8c0;
  margin-top: 0.25rem;
  min-height: 1.2em;
}

.oware-board {
  width: 100%;
  max-width: 340px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  align-items: center;
}

.row-label {
  font-size: 0.65rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #8890b0;
  align-self: center;
}

.pit-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.pit-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.pit-number {
  font-size: 0.65rem;
  color: #8890b0;
}

.pit {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #283056;
  background: #181d36;
  transition: all 0.15s ease;
}

.pit-opponent {
  background: #2a1b38;
  border-color: #884477;
}

.pit-player {
  background: #182e4b;
  border-color: #38bdf8;
  cursor: pointer;
}

/* Two-player mode: the top row becomes Player 2's interactive row. */
.two-player-button {
  width: 100%;
  margin-top: 0.6rem;
}

.pit-opponent.pit-valid {
  cursor: pointer;
}

.pit-number-valid {
  color: #f59e0b;
  font-weight: 700;
}

.result-scores {
  font-family: "DM Sans", sans-serif;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #e6e8f2;
  margin: 0.35rem 0 0.75rem;
}

.pit-valid {
  border-color: #f59e0b;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.5);
  animation: pulse-ring 1.1s ease-in-out infinite alternate;
}

@keyframes pulse-ring {
  from { box-shadow: 0 0 4px rgba(245, 158, 11, 0.3); }
  to { box-shadow: 0 0 12px rgba(245, 158, 11, 0.7); }
}

.pit-count {
  font-size: 1.1rem;
  font-weight: 700;
  color: #fbbf24;
}

.stores-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  padding: 0.5rem 0;
}

/* 1-6 number buttons */
.number-button-row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 0.4rem;
}

.btn-number {
  width: 44px;
  height: 40px;
  border-radius: 8px;
  border: 2px solid #283056;
  background: #181d36;
  color: #f0f0f0;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-number-valid {
  border-color: #f59e0b;
  color: #fbbf24;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.45);
}

.btn-number:active {
  transform: scale(0.94);
}

/* New row BELOW the 1-6 buttons: How to Play (left) + Quit (right) */
/* STILL AHEAD SCREEN */
.screen-stillahead {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  align-items: center;
  justify-content: flex-start;
  padding: 2rem 1rem;
}
.stillahead-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  width: 100%;
  max-width: 560px;
  margin: auto;
}
.still-ahead-title {
  font-size: 1.8rem;
  letter-spacing: 0.12em;
  color: #ffd700;
  text-shadow: 0 0 18px rgba(255, 215, 0, 0.45);
  margin: 0;
}
.stillahead-sub {
  color: #cfcfcf;
  font-size: 0.95rem;
  margin: 0 0 0.5rem;
  text-align: center;
}
.stillahead-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 1rem;
  width: 100%;
}
.stillahead-card {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 215, 0, 0.25);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}
.stillahead-avatar {
  width: 84px;
  height: 84px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.25);
  flex: 0 0 auto;
}
.stillahead-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 18% 15%;
  transform: scale(1.18);
  transform-origin: 22% 18%;
  display: block;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.25);
}
.stillahead-name {
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.04em;
}
.stillahead-title-text {
  font-size: 0.8rem;
  color: #b9b9b9;
}
.sound-toggle-row {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.board-action-row {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  margin-top: 0.5rem;
}

.board-action-row .btn-secondary {
  margin-top: 0;
  flex: 1 1 0;
}

.total-seeds {
  font-size: 0.8rem;
  letter-spacing: 0.1em;
  color: #a0a8c0;
  text-transform: uppercase;
}

.store {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem 1rem;
  border-radius: 8px;
  min-width: 70px;
}

.store-theirs {
  background: rgba(168, 85, 247, 0.15);
  border: 1px solid #a855f7;
}

.store-yours {
  background: rgba(16, 185, 129, 0.15);
  border: 1px solid #10b981;
}

.store-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #a0a8c0;
}

.store-count {
  font-size: 1.4rem;
  font-weight: 900;
  color: #f0f0f0;
}

.board-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  max-width: 340px;
  margin-top: 0.4rem;
  padding: 0 0.5rem;
}

.target-info {
  font-size: 0.85rem;
  color: #a0a8c0;
}

.btn-small {
  padding: 0.5rem 1.2rem;
  font-size: 0.85rem;
}

/* HELP BUTTON (board screen top corner) */
.btn-help {
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 20;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid rgba(255, 215, 0, 0.5);
  background: rgba(255, 255, 255, 0.08);
  color: #ffd700;
  font-size: 1.3rem;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.btn-help:hover {
  background: rgba(255, 215, 0, 0.18);
  border-color: #ffd700;
}

.btn-help:active {
  transform: scale(0.94);
}

/* HOW TO PLAY SCREEN */
.screen-howtoplay {
  background: rgba(14, 17, 32, 0.98);
  justify-content: flex-start;
  padding: 2rem 1.25rem;
}

.howtoplay-content {
  width: 100%;
  max-width: 560px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.howtoplay-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ffd700;
  margin-bottom: 1.25rem;
  text-align: center;
}

.howtoplay-text {
  flex: 1 1 auto;
  width: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  text-align: left;
  color: #f0f0f0;
  line-height: 1.6;
  padding: 0 0.25rem 1rem;
}

.howtoplay-text p {
  margin-bottom: 1rem;
  font-size: 1rem;
}

.howtoplay-text strong {
  color: #ffd700;
  font-weight: 700;
}

.howtoplay-tip {
  font-style: italic;
  color: #a0f0c0;
  border-left: 3px solid rgba(16, 185, 129, 0.6);
  padding-left: 0.85rem;
}

.howtoplay-content .btn-secondary {
  flex: 0 0 auto;
  margin-top: 1rem;
}

/* MENU SECONDARY ROW (How to Play + Credits side by side) */
.menu-secondary-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.menu-secondary-row .btn-secondary {
  margin-top: 1rem;
}

/* CREDITS SCREEN */
.screen-credits {
  background: rgba(14, 17, 32, 0.98);
  padding: 2rem 1.25rem;
}

.credits-content {
  text-align: center;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.credits-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  color: #ffd700;
  margin-bottom: 1.5rem;
}

.credits-line {
  font-size: 1rem;
  color: #d0d0d0;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

/* RESPONSIVE */
@media (max-width: 640px) {
  .game-title {
    font-size: 2.5rem;
  }
  
  .greeting-content h2 {
    font-size: 1.8rem;
  }
  
  .proverb {
    font-size: 1rem;
  }
  
  .result-content h2 {
    font-size: 2.2rem;
  }
  
  .btn-primary,
  .btn-secondary {
    padding: 0.9rem 2rem;
    font-size: 1rem;
  }
}