:root {
  color-scheme: dark;
  --ink: #0a1712;
  --paper: #fff8d7;
  --lime: #a8d91d;
  --sudachi: #4e961e;
  --gold: #f3c53b;
  --warning: #ff625c;
  --panel: rgba(7, 20, 15, 0.82);
  --line: rgba(255, 248, 215, 0.24);
  --shadow: 0 18px 44px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100%;
  min-height: 100svh;
  overflow: hidden;
  isolation: isolate;
  background:
    linear-gradient(135deg, rgba(255, 248, 215, 0.04) 0 12%, transparent 12% 24%, rgba(255, 248, 215, 0.03) 24% 36%, transparent 36%),
    linear-gradient(180deg, #173927 0%, #234f2f 46%, #16281f 100%);
  touch-action: none;
}

#gameCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  display: block;
  touch-action: none;
}

.hud {
  position: fixed;
  z-index: 4;
  top: calc(10px + env(safe-area-inset-top, 0px));
  left: calc(10px + env(safe-area-inset-left, 0px));
  right: calc(10px + env(safe-area-inset-right, 0px));
  width: auto;
  display: grid;
  grid-template-columns: minmax(140px, 1fr) auto 44px;
  align-items: center;
  gap: 10px;
  pointer-events: none;
}

.brand,
.stats,
.icon-button,
.combo-badge,
.modal-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.brand {
  min-width: 0;
  height: 58px;
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 7px 10px 7px 7px;
  border-radius: 8px;
}

.brand-avatar {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  object-fit: cover;
  object-position: 50% 18%;
  background: #ffffff;
}

.brand-copy {
  min-width: 0;
}

.brand-copy span,
.stat span,
.record-row span,
.kicker,
.result-score span {
  display: block;
  color: rgba(255, 248, 215, 0.74);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.1;
}

.brand-copy strong {
  display: block;
  margin-top: 3px;
  color: var(--paper);
  font-size: 1.05rem;
  line-height: 1.05;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stats {
  height: 58px;
  display: grid;
  grid-template-columns: repeat(3, 76px);
  gap: 1px;
  overflow: hidden;
  border-radius: 8px;
}

.stat {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 4px;
  min-width: 0;
  background: rgba(255, 255, 255, 0.04);
}

.stat strong {
  color: var(--paper);
  font-size: 1.24rem;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.icon-button {
  pointer-events: auto;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: var(--paper);
  cursor: pointer;
}

.icon-button span {
  display: block;
  font-weight: 900;
  line-height: 1;
}

.icon-button:active,
.primary-button:active {
  transform: translateY(1px);
}

.combo-badge {
  position: fixed;
  z-index: 3;
  top: calc(82px + env(safe-area-inset-top, 0px));
  left: 50%;
  min-width: 132px;
  padding: 10px 14px;
  border-radius: 8px;
  transform: translateX(-50%) scale(0.96);
  color: var(--gold);
  text-align: center;
  font-weight: 900;
  line-height: 1;
  opacity: 0;
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
}

.combo-badge.is-live {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  padding:
    calc(20px + env(safe-area-inset-top, 0px))
    calc(16px + env(safe-area-inset-right, 0px))
    calc(20px + env(safe-area-inset-bottom, 0px))
    calc(16px + env(safe-area-inset-left, 0px));
  background:
    linear-gradient(180deg, rgba(10, 23, 18, 0.24), rgba(10, 23, 18, 0.76)),
    rgba(10, 23, 18, 0.28);
}

.overlay[hidden] {
  display: none;
}

.modal-panel {
  width: min(390px, 100%);
  border-radius: 8px;
  padding: 20px;
  text-align: center;
}

.modal-mascot {
  width: 128px;
  height: 128px;
  display: block;
  margin: 0 auto 14px;
  border: 3px solid var(--gold);
  border-radius: 8px;
  object-fit: cover;
  object-position: 50% 15%;
  background: #ffffff;
}

.kicker {
  color: var(--lime);
}

h1,
h2 {
  margin: 8px 0 14px;
  color: var(--paper);
  font-weight: 950;
  line-height: 1.02;
  letter-spacing: 0;
}

h1 {
  font-size: 2.65rem;
}

h2 {
  font-size: 2.2rem;
}

.record-row,
.result-score {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin: 10px auto 16px;
  color: var(--paper);
  font-variant-numeric: tabular-nums;
}

.record-row strong {
  color: var(--gold);
  font-size: 1.4rem;
}

.result-score strong {
  color: var(--paper);
  font-size: 3rem;
  line-height: 1;
}

.primary-button {
  width: min(260px, 100%);
  min-height: 52px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(180deg, #ffe36d, #f1b92f);
  color: #1c1608;
  box-shadow: 0 10px 0 #9a6817, 0 18px 34px rgba(0, 0, 0, 0.28);
  font-weight: 950;
  cursor: pointer;
}

@media (max-width: 620px) {
  .hud {
    grid-template-columns: 1fr 44px;
    grid-template-areas:
      "brand pause"
      "stats stats";
    align-items: start;
  }

  .brand {
    grid-area: brand;
    justify-self: stretch;
  }

  .stats {
    grid-area: stats;
    min-width: 0;
    width: auto;
    justify-self: stretch;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .icon-button {
    grid-area: pause;
    justify-self: end;
  }

  .combo-badge {
    top: calc(144px + env(safe-area-inset-top, 0px));
  }
}

@media (max-width: 360px), (max-height: 620px) {
  .brand {
    height: 52px;
    grid-template-columns: 38px minmax(0, 1fr);
  }

  .brand-avatar {
    width: 38px;
    height: 38px;
  }

  .brand-copy strong {
    font-size: 0.95rem;
  }

  .stats {
    height: 52px;
  }

  .stat strong {
    font-size: 1.08rem;
  }

  .modal-panel {
    padding: 16px;
  }

  .modal-mascot {
    width: 104px;
    height: 104px;
  }

  h1 {
    font-size: 2.18rem;
  }

  h2 {
    font-size: 1.9rem;
  }
}
