:root {
  --bg-top: #10233d;
  --bg-bottom: #020811;
  --panel: rgba(3, 10, 20, 0.84);
  --line: #99d6ff;
  --ice-1: #d9f4ff;
  --ice-2: #c1e8fb;
  --red: #d12e2e;
  --yellow: #e6be2f;
  --text: #f3f8ff;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  font-family: 'Trebuchet MS', 'Segoe UI', sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 50% 0, #1d3f67 0%, var(--bg-top) 35%, var(--bg-bottom) 100%);
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  min-height: 100%;
  padding: 12px;
  display: grid;
  gap: 10px;
  grid-template-rows: auto 1fr auto;
}

.top-hud,
.bottom-hud {
  background: var(--panel);
  border: 2px solid #3c7ba4;
  box-shadow: inset 0 0 40px rgba(61, 126, 163, 0.25), 0 8px 20px rgba(0, 0, 0, 0.3);
}

.top-hud {
  padding: 10px 14px;
  display: grid;
  grid-template-columns: 180px 1fr 180px;
  align-items: center;
}

.team-block {
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-radius: 8px;
  padding: 8px;
  display: grid;
  gap: 6px;
  font-weight: 700;
}

.team-main {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.team-block .score {
  font-size: 1.4rem;
}

.stones-left {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  min-height: 14px;
}

.stone-chip {
  --stone-fill: #d12e2e;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1px solid rgba(97, 107, 120, 0.92);
  position: relative;
  background: radial-gradient(circle at 30% 28%, #d3dae1, #8d98a4);
}

.stone-chip::before {
  content: '';
  position: absolute;
  width: 6px;
  height: 6px;
  left: 1px;
  top: 1px;
  border-radius: 50%;
  background: var(--stone-fill);
  border: 1px solid rgba(21, 45, 66, 0.4);
}

.stone-chip::after {
  content: '';
  position: absolute;
  width: 3px;
  height: 2px;
  border-radius: 2px;
  left: 3px;
  top: 4px;
  background: #7f8995;
  border: 1px solid rgba(56, 66, 76, 0.58);
}

.stone-chip.red {
  --stone-fill: #d12e2e;
}

.stone-chip.yellow {
  --stone-fill: #e6be2f;
}

.stone-chip.used {
  opacity: 0.22;
  filter: grayscale(0.2);
}

.team-block.red {
  background: linear-gradient(180deg, rgba(209, 46, 46, 0.45), rgba(117, 22, 22, 0.5));
}

.team-block.yellow {
  background: linear-gradient(180deg, rgba(230, 190, 47, 0.45), rgba(126, 92, 12, 0.48));
}

.center-status {
  text-align: center;
  line-height: 1.35;
  font-weight: 700;
}

.rink-wrap {
  position: relative;
  display: grid;
  place-items: center;
  border: 3px solid #5a97bd;
  border-radius: 10px;
  overflow: hidden;
  background: #0c2136;
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.35);
}

#game-canvas {
  display: block;
  width: 70%;
  max-width: 100%;
  height: auto;
  aspect-ratio: 840 / 1080;
}

.crt-overlay {
  pointer-events: none;
  position: absolute;
  inset: 0;
  background-image:
    linear-gradient(to bottom, rgba(255, 255, 255, 0.06) 1px, rgba(0, 0, 0, 0) 1px),
    radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.1), transparent 55%);
  background-size: 100% 3px, 100% 100%;
  mix-blend-mode: soft-light;
}

.final-screen {
  position: absolute;
  inset: 0;
  background: rgba(3, 8, 20, 0.8);
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 700;
  backdrop-filter: blur(3px);
}

.final-screen.hidden {
  display: none;
}

.bottom-hud {
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr)) 1.4fr;
  gap: 10px;
  align-items: end;
}

.meter-block {
  display: grid;
  gap: 4px;
}

.meter {
  height: 14px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: rgba(0, 0, 0, 0.45);
  position: relative;
  overflow: hidden;
}

.fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 0%;
  transition: width 80ms linear;
}

.fill.power {
  background: linear-gradient(90deg, #56f9ff, #0f7dd8);
}

.fill.spin {
  background: linear-gradient(90deg, #f7f7f7, #38d08e);
}

.fill.friction {
  background: linear-gradient(90deg, #a7f3ff, #18d8d5);
}

.controls {
  text-align: right;
  font-size: 0.9rem;
  opacity: 0.9;
}

@media (max-width: 900px) {
  .top-hud {
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .bottom-hud {
    grid-template-columns: 1fr;
  }

  .controls {
    text-align: left;
  }

  #game-canvas {
    width: 100%;
  }
}
