:root {
  --bone: #eee7d7;
  --muted: #9da294;
  --night: #040705;
  --night-soft: #0a110c;
  --moss: #93ad79;
  --moss-light: #d1e5ad;
  --ember: #c27c50;
  --line: rgba(238, 231, 215, .16);
  --line-strong: rgba(238, 231, 215, .34);
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html, body { min-width: 320px; min-height: 100%; }

body {
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 15%, rgba(147, 173, 121, .12), transparent 34rem),
    linear-gradient(180deg, #071009, var(--night) 56%);
  color: var(--bone);
}

body::before {
  position: fixed;
  inset: 0;
  z-index: 100;
  pointer-events: none;
  content: "";
  opacity: .11;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 160 160' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='3'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.35'/%3E%3C/svg%3E");
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }

.arcade-shell {
  width: min(calc(100% - 32px), 1160px);
  margin: 0 auto;
  padding: 28px 0 48px;
}

.game-header {
  min-height: 76px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 24px;
}

.back-link,
.sound-button {
  color: var(--muted);
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .17em;
  text-decoration: none;
  text-transform: uppercase;
}

.back-link:hover,
.back-link:focus-visible,
.sound-button:hover,
.sound-button:focus-visible { color: var(--moss-light); }

.sound-button {
  justify-self: end;
  padding: 10px 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.game-title { text-align: center; }
.game-title span {
  color: var(--moss-light);
  font-size: .64rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.game-title h1 {
  margin: 4px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2rem, 4vw, 3.6rem);
  font-weight: 400;
  line-height: .9;
  letter-spacing: -.045em;
}

.cabinet {
  position: relative;
  padding: clamp(14px, 2vw, 25px);
  border: 1px solid var(--line-strong);
  background:
    linear-gradient(145deg, rgba(238,231,215,.045), transparent 18%),
    #0b100c;
  box-shadow: 0 32px 100px rgba(0,0,0,.55);
}

.cabinet::before,
.cabinet::after {
  position: absolute;
  top: 12px;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--line-strong);
  content: "";
}
.cabinet::before { left: 12px; }
.cabinet::after { right: 12px; }

.cabinet-top {
  padding: 0 12px 16px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 20px;
}

.score-block { display: flex; align-items: baseline; gap: 14px; }
.score-block-right { justify-content: flex-end; }
.score-block span,
.match-state span {
  color: var(--muted);
  font-size: .62rem;
  font-weight: 700;
  letter-spacing: .18em;
  text-transform: uppercase;
}
.score-block strong {
  color: var(--moss-light);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.8rem, 7vw, 5.4rem);
  font-weight: 400;
  line-height: .8;
}
.match-state { text-align: center; }
.match-state strong {
  margin-top: 8px;
  display: block;
  color: var(--bone);
  font-size: .7rem;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.screen-frame {
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(209,229,173,.26);
  background: #020403;
  box-shadow:
    inset 0 0 50px rgba(0,0,0,.9),
    0 0 55px rgba(147,173,121,.07);
}

canvas {
  width: 100%;
  height: auto;
  display: block;
  aspect-ratio: 16 / 9;
  touch-action: none;
  image-rendering: pixelated;
}

.screen-glass {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
  background:
    repeating-linear-gradient(to bottom, rgba(209,229,173,.026) 0 1px, transparent 2px 5px),
    radial-gradient(ellipse at center, transparent 48%, rgba(0,0,0,.68) 100%),
    linear-gradient(105deg, transparent 0 46%, rgba(255,255,255,.025) 49%, transparent 52%);
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  text-align: center;
  background: rgba(2,4,3,.82);
  backdrop-filter: blur(4px);
  transition: opacity .22s ease;
}
.game-overlay[hidden] { display: none; }

.overlay-sigil {
  position: relative;
  width: 88px;
  aspect-ratio: 1;
  margin-bottom: 24px;
  border: 1px solid rgba(209,229,173,.5);
  border-radius: 50%;
}
.overlay-sigil::before,
.overlay-sigil::after {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 136%;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(209,229,173,.45), transparent);
  content: "";
  transform: translate(-50%, -50%);
}
.overlay-sigil::after { transform: translate(-50%, -50%) rotate(90deg); }
.overlay-sigil span {
  position: absolute;
  inset: 29%;
  border: 1px solid var(--moss-light);
  transform: rotate(45deg);
}

.overlay-kicker {
  margin: 0 0 10px;
  color: var(--moss-light);
  font-size: .63rem;
  font-weight: 700;
  letter-spacing: .24em;
  text-transform: uppercase;
}
.game-overlay h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(3rem, 8vw, 6.5rem);
  font-weight: 400;
  line-height: .9;
  letter-spacing: -.06em;
}
.game-overlay > p:not(.overlay-kicker):not(.overlay-controls) {
  max-width: 520px;
  margin: 22px 0 0;
  color: var(--muted);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1rem;
  line-height: 1.6;
}

.mode-buttons {
  margin-top: 30px;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}
.mode-buttons button,
.restart-button {
  min-height: 48px;
  padding: 12px 18px;
  border: 1px solid rgba(209,229,173,.45);
  background: rgba(147,173,121,.08);
  color: var(--bone);
  font-size: .69rem;
  font-weight: 700;
  letter-spacing: .15em;
  text-transform: uppercase;
  cursor: pointer;
}
.mode-buttons button:first-child { background: var(--moss); color: #071008; }
.mode-buttons button:hover,
.mode-buttons button:focus-visible,
.restart-button:hover,
.restart-button:focus-visible { border-color: var(--moss-light); background: var(--moss-light); color: #071008; }
.restart-button { margin-top: 30px; }
.overlay-controls {
  margin: 22px 0 0;
  color: rgba(238,231,215,.45);
  font-size: .6rem;
  letter-spacing: .16em;
  text-transform: uppercase;
}

.mobile-controls {
  margin-top: 14px;
  display: none;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.touch-zone { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.touch-zone button {
  min-height: 58px;
  border: 1px solid var(--line-strong);
  background: rgba(238,231,215,.035);
  color: var(--moss-light);
  font-size: 1.2rem;
  touch-action: none;
}
.touch-zone button.is-active { background: rgba(147,173,121,.2); }

.game-footer {
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--muted);
  font-size: .63rem;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.game-footer p { margin: 0; }
.game-footer p:last-child { color: var(--moss-light); text-align: right; }

@media (pointer: coarse), (max-width: 760px) {
  .mobile-controls { display: grid; }
}

@media (max-width: 680px) {
  .arcade-shell { width: min(calc(100% - 18px), 1160px); padding-top: 12px; }
  .game-header { min-height: 66px; grid-template-columns: 1fr auto; }
  .game-title { grid-column: 1 / -1; grid-row: 1; }
  .back-link { grid-column: 1; grid-row: 2; }
  .sound-button { grid-column: 2; grid-row: 2; }
  .cabinet { padding: 10px; }
  .cabinet-top { padding: 4px 4px 12px; gap: 8px; }
  .score-block { gap: 7px; flex-direction: column; align-items: flex-start; }
  .score-block-right { align-items: flex-end; }
  .score-block strong { font-size: 3.3rem; }
  .match-state span { display: none; }
  .game-overlay { padding: 16px; }
  .overlay-sigil { width: 66px; margin-bottom: 16px; }
  .game-overlay h2 { font-size: clamp(2.8rem, 16vw, 4.8rem); }
  .game-overlay > p:not(.overlay-kicker):not(.overlay-controls) { margin-top: 14px; font-size: .88rem; }
  .mode-buttons { margin-top: 20px; flex-direction: column; }
  .mode-buttons button { width: min(280px, 74vw); }
  .mobile-controls { grid-template-columns: 1fr; }
  .touch-zone-right { display: none; }
  body.is-duel .mobile-controls { grid-template-columns: 1fr 1fr; }
  body.is-duel .touch-zone-right { display: grid; }
  .game-footer { padding: 16px 4px; align-items: flex-start; flex-direction: column; }
  .game-footer p:last-child { text-align: left; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
