:root {
  --ice: #dce9f0;
  --ice-line: #9fc3d6;
  --red: #c23b3b;
  --yellow: #e0b020;
  --panel: #152238;
  --panel-text: #f2f5f8;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: #0d1526;
  color: var(--panel-text);
  display: flex;
  justify-content: center;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
}

.layout {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  height: 100%;
}

.scoreboard {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--panel);
}

.team {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
  padding: 6px 10px;
  border-radius: 8px;
  opacity: 0.55;
  transition: opacity 0.2s, box-shadow 0.2s;
}

.team.active {
  opacity: 1;
  box-shadow: 0 0 0 2px currentColor inset;
}

.team-red { color: var(--red); }
.team-yellow { color: var(--yellow); }

.team-name { font-size: 13px; letter-spacing: 0.04em; text-transform: uppercase; }
.team-score { font-size: 28px; font-weight: 700; }

.end-info {
  text-align: center;
  font-size: 13px;
  line-height: 1.5;
  color: #c7d2e0;
}

#turn-label { font-weight: 600; color: #fff; }

.rink-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0d1526;
  overflow: hidden;
}

canvas#rink {
  background: var(--ice);
  touch-action: none;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
}

.toast {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(21, 34, 56, 0.92);
  border: 2px solid #334568;
  color: var(--panel-text);
  padding: 16px 28px;
  border-radius: 28px;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  max-width: 90%;
  box-sizing: border-box;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s;
  z-index: 2;
}

.toast.visible { opacity: 1; }

.end-overlay {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(10, 16, 30, 0.72);
}

.end-overlay.visible { display: flex; }

.end-overlay-card {
  background: var(--panel);
  padding: 24px 28px;
  border-radius: 12px;
  text-align: center;
  max-width: 340px;
}

.end-overlay-card h2 { margin: 0 0 8px; }
.end-overlay-card p { margin: 0 0 16px; color: #c7d2e0; }

.team-name-field {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin-bottom: 12px;
  text-align: left;
}

.team-name-field label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8fa3bf;
}

.team-name-field input,
.team-name-field select {
  width: 100%;
  background: #0d1526;
  color: var(--panel-text);
  border: 1px solid #334568;
  border-radius: 6px;
  padding: 8px 10px;
  font-size: 15px;
}

.team-name-field input:focus,
.team-name-field select:focus {
  outline: none;
  border-color: #3a81c4;
}

.mode-toggle {
  width: 100%;
  flex-wrap: wrap;
}

.mode-toggle .turn-btn {
  flex: 1 1 0;
  font-size: 13px;
  padding: 8px 8px;
  line-height: 1.3;
}

#next-end-btn, #start-game-btn {
  background: #2d6ca8;
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 6px;
  font-size: 15px;
  cursor: pointer;
}

#next-end-btn:hover, #start-game-btn:hover { background: #3a81c4; }

.controls {
  background: var(--panel);
  padding: 12px 16px 18px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.control-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.control-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #8fa3bf;
}

.turn-toggle { display: flex; gap: 6px; }

.turn-btn, .sweep-btn {
  background: #223455;
  color: var(--panel-text);
  border: 1px solid #334568;
  padding: 8px 14px;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  user-select: none;
}

.turn-btn.selected {
  background: #2d6ca8;
  border-color: #3a81c4;
}

.sweep-btn.sweeping {
  background: #c23b3b;
  border-color: #e05050;
}

.instructions {
  flex: 1 1 100%;
  font-size: 12px;
  color: #8fa3bf;
  line-height: 1.5;
}

@media (max-height: 720px) {
  .scoreboard { padding: 6px 12px; }
  .team-score { font-size: 22px; }
  .end-info { font-size: 12px; }
  .controls { padding: 8px 12px 10px; gap: 8px; }
  .turn-btn, .sweep-btn { padding: 6px 10px; font-size: 13px; }
  .instructions { display: none; }
}

@media (pointer: coarse) {
  .space-hint { display: none; }
}
