:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #101113;
  color: #f4f0e8;
  --panel: rgba(16, 17, 19, 0.62);
  --line: rgba(244, 240, 232, 0.16);
  --text-soft: rgba(244, 240, 232, 0.64);
  --accent: #d9b56f;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #101113;
}

button {
  font: inherit;
}

.shell {
  position: fixed;
  inset: 0;
  min-width: 320px;
  min-height: 420px;
  overflow: hidden;
  touch-action: manipulation;
  user-select: none;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  outline: none;
}

.hud {
  position: absolute;
  z-index: 3;
  top: max(18px, env(safe-area-inset-top));
  left: max(18px, env(safe-area-inset-left));
  right: max(18px, env(safe-area-inset-right));
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: start;
  pointer-events: none;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.hud__item {
  display: flex;
  gap: 9px;
  align-items: baseline;
  color: var(--text-soft);
  font-size: 12px;
}

.hud__item strong {
  color: #f4f0e8;
  font-size: 14px;
}

.hud__score {
  min-width: 96px;
  text-align: center;
  font-size: clamp(42px, 8vh, 86px);
  font-weight: 650;
  line-height: 0.86;
  letter-spacing: 0;
  color: rgba(244, 240, 232, 0.94);
  text-shadow: 0 18px 48px rgba(0, 0, 0, 0.3);
}

.sound {
  justify-self: end;
  pointer-events: auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(244, 240, 232, 0.05);
  color: rgba(244, 240, 232, 0.78);
  min-height: 36px;
  padding: 0 13px;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px;
}

.sound span {
  color: #f4f0e8;
  margin-left: 7px;
}

.sound:focus-visible,
.panel button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.panel {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 50%;
  width: min(360px, calc(100vw - 42px));
  transform: translate(-50%, -48%) scale(0.98);
  opacity: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  gap: 16px;
  padding: 28px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(22px);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.34);
  transition: opacity 280ms ease, transform 280ms ease;
  text-align: center;
}

.panel.is-visible {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.panel h1,
.panel h2,
.panel p {
  margin: 0;
}

.panel h1 {
  font-size: clamp(46px, 11vw, 76px);
  line-height: 0.9;
  font-weight: 720;
  letter-spacing: 0;
}

.panel h2 {
  font-size: 28px;
  line-height: 1;
  font-weight: 680;
  letter-spacing: 0;
}

.panel p,
.panel small {
  color: var(--text-soft);
}

.panel small {
  font-size: 12px;
}

.panel button {
  min-width: 142px;
  min-height: 42px;
  border: 0;
  border-radius: 999px;
  background: #f4f0e8;
  color: #121314;
  cursor: pointer;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 12px;
  font-weight: 720;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.28);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.panel .button-secondary {
  border: 1px solid var(--line);
  background: rgba(244, 240, 232, 0.06);
  color: #f4f0e8;
  box-shadow: none;
}

.results {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.results div {
  min-width: 0;
  padding: 12px 8px;
  border: 1px solid rgba(244, 240, 232, 0.11);
  border-radius: 7px;
  background: rgba(244, 240, 232, 0.04);
}

.results span {
  display: block;
  color: var(--text-soft);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-size: 10px;
}

.results strong {
  display: block;
  margin-top: 5px;
  font-size: 25px;
  line-height: 1;
}

.share-preview {
  width: 100%;
  margin: -2px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(244, 240, 232, 0.1);
  border-radius: 7px;
  background: rgba(244, 240, 232, 0.035);
  color: rgba(244, 240, 232, 0.78);
  font-size: 12px;
  line-height: 1.45;
  text-align: left;
}

.toast {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 22%;
  transform: translate(-50%, 12px) scale(0.98);
  opacity: 0;
  color: #f4f0e8;
  font-size: clamp(15px, 2.8vw, 20px);
  font-weight: 720;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  text-shadow: 0 14px 32px rgba(0, 0, 0, 0.48);
  pointer-events: none;
  transition: opacity 220ms ease, transform 220ms ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0) scale(1);
}

@media (max-width: 620px) {
  .hud {
    top: max(14px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    right: max(12px, env(safe-area-inset-right));
  }

  .hud__item {
    flex-direction: column;
    gap: 2px;
  }

  .sound {
    min-height: 34px;
    padding: 0 11px;
    font-size: 10px;
  }

  .results {
    grid-template-columns: repeat(2, 1fr);
  }

  .actions {
    width: 100%;
  }

  .panel button {
    min-width: min(142px, 100%);
  }

  .panel {
    padding: 24px 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .panel,
  .toast {
    transition-duration: 80ms;
  }
}
