:root {
  color-scheme: light;
  --navy-950: #061425;
  --navy-900: #071a2f;
  --navy-800: #0e2945;
  --navy-700: #183c5d;
  --ice-50: #f5fbfd;
  --ice-100: #e9f5f8;
  --ice-200: #d4e9ef;
  --ice-300: #b8d9e2;
  --red-600: #cb3d34;
  --red-500: #e05246;
  --gold-500: #d5a84f;
  --ink: #10283d;
  --muted: #61798c;
  --line: rgba(14, 41, 69, 0.13);
  --shadow: 0 20px 50px rgba(4, 24, 42, 0.12);
  --serif: "Yu Mincho", "Hiragino Mincho ProN", "Hiragino Mincho Pro", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--ice-50);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 4% 4%, rgba(144, 205, 219, 0.26), transparent 23rem),
    linear-gradient(180deg, #f7fcfd 0%, #edf7f9 100%);
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.site-header {
  position: sticky;
  z-index: 20;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 10px clamp(18px, 4vw, 60px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  color: white;
  background: rgba(6, 20, 37, 0.97);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  position: relative;
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}

.brand-mark::before {
  width: 24px;
  height: 24px;
  content: "";
  border: 4px solid var(--red-500);
  border-radius: 50%;
  box-shadow: inset 0 0 0 4px white;
}

.brand-mark span {
  position: absolute;
  top: 8px;
  width: 18px;
  height: 5px;
  border-radius: 8px;
  background: var(--gold-500);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 1.05;
}

.brand-copy strong {
  font-family: var(--serif);
  font-size: 19px;
  letter-spacing: 0.08em;
}

.brand-copy small {
  margin-top: 5px;
  color: #91b4c8;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.22em;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
}

.mode-chip {
  padding: 7px 12px;
  border: 1px solid rgba(213, 168, 79, 0.6);
  border-radius: 999px;
  color: #f3d38d;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.text-button {
  padding: 8px 2px;
  border: 0;
  border-bottom: 1px solid transparent;
  color: #dce9ee;
  background: transparent;
  cursor: pointer;
}

.text-button:hover,
.text-button:focus-visible {
  border-color: currentColor;
  outline: none;
}

.page-shell {
  width: min(1280px, calc(100% - 40px));
  margin: 0 auto;
  padding: 18px 0 36px;
}

.intro-copy {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 12px;
}

.eyebrow,
.panel-kicker {
  margin: 0 0 6px;
  color: #55778d;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.2em;
}

.intro-copy h1 {
  margin: 0;
  color: var(--navy-900);
  font-family: var(--serif);
  font-size: clamp(25px, 2.6vw, 34px);
  font-weight: 700;
  letter-spacing: 0.05em;
}

.intro-rule {
  max-width: 370px;
  margin: 0 0 3px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
  text-align: right;
}

.game-layout {
  display: grid;
  grid-template-columns: clamp(280px, calc((100dvh - 275px) * 0.6441), 600px) 340px;
  gap: 20px;
  align-items: start;
  justify-content: center;
}

.rink-card,
.panel {
  border: 1px solid rgba(16, 40, 61, 0.11);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: var(--shadow);
}

.rink-card {
  width: 100%;
  overflow: hidden;
  border-color: rgba(16, 40, 61, 0.18);
  background: var(--navy-950);
}

.rink-topline,
.rink-footer {
  display: grid;
  align-items: center;
  color: #bcd1dc;
  background: var(--navy-950);
}

.rink-topline {
  grid-template-columns: auto 1fr auto;
  min-height: 48px;
  padding: 8px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.09);
  font-size: 12px;
}

.rink-topline p {
  overflow: hidden;
  margin: 0 16px;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.throw-dots {
  display: flex;
  gap: 7px;
}

.throw-dot {
  display: block;
  width: 9px;
  height: 9px;
  border: 1px solid #7894a5;
  border-radius: 50%;
}

.throw-dot.is-current {
  border-color: var(--red-500);
  background: var(--red-500);
  box-shadow: 0 0 0 3px rgba(224, 82, 70, 0.18);
}

.throw-dot.is-used {
  border-color: #708696;
  background: #708696;
}

.round-timer {
  color: white;
  font-variant-numeric: tabular-nums;
  font-weight: 750;
  letter-spacing: 0.08em;
}

.rink-stage {
  position: relative;
  display: grid;
  width: 100%;
  place-items: center;
  background: var(--navy-950);
}

#gameCanvas {
  display: block;
  width: 100%;
  height: auto;
  outline: none;
  cursor: grab;
  touch-action: none;
}

#gameCanvas:active {
  cursor: grabbing;
}

#gameCanvas:focus-visible {
  box-shadow: inset 0 0 0 4px #e7b85d;
}

.gesture-tip {
  position: absolute;
  bottom: 8.5%;
  left: 50%;
  display: flex;
  min-width: 240px;
  padding: 14px 16px 14px 52px;
  transform: translateX(-50%);
  flex-direction: column;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  color: white;
  background: rgba(6, 25, 43, 0.88);
  box-shadow: 0 10px 24px rgba(4, 24, 42, 0.24);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

.gesture-tip.is-hidden {
  opacity: 0;
  transform: translate(-50%, 12px);
}

.gesture-tip strong {
  font-size: 14px;
}

.gesture-tip small {
  margin-top: 4px;
  color: #bcd3dd;
  font-size: 10px;
}

.gesture-line {
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 27px;
  width: 2px;
  background: var(--red-500);
}

.gesture-line::before {
  position: absolute;
  top: -1px;
  left: -4px;
  width: 8px;
  height: 8px;
  content: "";
  transform: rotate(45deg);
  border-top: 2px solid white;
  border-left: 2px solid white;
}

.rink-footer {
  grid-template-columns: 1fr auto;
  min-height: 38px;
  padding: 8px 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 10px;
  letter-spacing: 0.04em;
}

.keyboard-help {
  color: #7996a8;
}

.control-rail {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 14px;
}

.panel {
  padding: 20px;
}

.panel-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading.compact {
  align-items: center;
}

.panel h2 {
  margin: 0;
  color: var(--navy-900);
  font-family: var(--serif);
  font-size: 20px;
}

.difficulty {
  flex: 0 0 auto;
  padding: 5px 8px;
  border-radius: 5px;
  color: #8c5d16;
  background: #f7e8c4;
  font-size: 10px;
  font-weight: 800;
}

.evidence-meter {
  margin: 22px 0;
}

.evidence-label {
  display: flex;
  justify-content: space-between;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
}

.evidence-label strong {
  color: var(--navy-800);
  font-variant-numeric: tabular-nums;
}

.meter-track {
  overflow: hidden;
  height: 6px;
  border-radius: 99px;
  background: var(--ice-200);
}

.meter-track span {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--red-600), #e98254);
  transition: width 400ms ease;
}

.answer-form label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.answer-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 9px;
}

.answer-row input {
  width: 100%;
  min-height: 46px;
  border: 1px solid #b8cbd5;
  border-radius: 9px;
  color: var(--navy-900);
  background: white;
  padding: 0 12px;
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 700;
  text-align: left;
}

.answer-row input:focus {
  border-color: var(--navy-700);
  outline: 3px solid rgba(24, 60, 93, 0.13);
}

.answer-row input:disabled {
  color: #9dafb9;
  background: #edf3f5;
}

.answer-row input.is-error {
  animation: shake 260ms ease;
  border-color: var(--red-500);
}

.primary-button {
  min-height: 46px;
  padding: 10px 15px;
  border: 0;
  border-radius: 9px;
  color: white;
  background: var(--red-600);
  box-shadow: 0 7px 16px rgba(177, 42, 35, 0.2);
  font-weight: 800;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}

.primary-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #b9332c;
  box-shadow: 0 9px 18px rgba(177, 42, 35, 0.26);
}

.primary-button:focus-visible {
  outline: 3px solid rgba(203, 61, 52, 0.2);
  outline-offset: 2px;
}

.primary-button:disabled {
  color: #91a2ad;
  background: #dfe8ec;
  box-shadow: none;
  cursor: not-allowed;
}

.primary-button.wide {
  width: 100%;
}

.secondary-button {
  min-height: 44px;
  padding: 9px 14px;
  border: 1px solid #b8cbd5;
  border-radius: 9px;
  color: var(--navy-800);
  background: white;
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:hover,
.secondary-button:focus-visible {
  border-color: var(--navy-700);
  outline: 3px solid rgba(24, 60, 93, 0.1);
}

.secondary-button.wide {
  width: 100%;
}

.answer-message {
  min-height: 38px;
  margin: 11px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.65;
}

.answer-message.is-success {
  color: #27734c;
  font-weight: 700;
}

.answer-message.is-error {
  color: #ae3731;
  font-weight: 700;
}

.shot-count {
  color: var(--muted);
  font-size: 11px;
}

.shot-count strong {
  color: var(--red-600);
  font-size: 18px;
}

.shot-list,
.tutorial-steps {
  display: grid;
  margin: 18px 0 0;
  padding: 0;
  gap: 12px;
  list-style: none;
}

.shot-list li,
.tutorial-steps li {
  display: grid;
  grid-template-columns: 30px 1fr;
  align-items: center;
  gap: 10px;
  color: #748895;
}

.shot-list li > span,
.tutorial-steps li > span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid #c8d7de;
  border-radius: 50%;
  font-size: 11px;
  font-weight: 850;
}

.shot-list div,
.tutorial-steps div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.shot-list strong,
.tutorial-steps strong {
  font-size: 12px;
}

.shot-list small,
.tutorial-steps small {
  font-size: 10px;
}

.shot-list li.is-active {
  color: var(--navy-900);
}

.shot-list li.is-active > span {
  border-color: var(--red-500);
  color: white;
  background: var(--red-500);
}

.shot-list li.is-done > span {
  border-color: var(--navy-700);
  color: white;
  background: var(--navy-700);
}

.player-record-panel {
  background: rgba(235, 246, 249, 0.92);
  box-shadow: none;
}

.player-record-panel > div {
  display: flex;
  min-width: 0;
  flex-direction: column;
}

.player-record-panel > div > strong {
  color: var(--navy-800);
  font-size: 12px;
}

.record-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  margin-top: 12px;
  gap: 5px;
}

.record-stats span {
  display: flex;
  min-width: 0;
  padding: 7px 4px;
  flex-direction: column;
  border: 1px solid rgba(24, 60, 93, 0.1);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  text-align: center;
}

.record-stats small {
  color: var(--muted);
  font-size: 9px;
}

.record-stats b {
  margin-top: 3px;
  color: var(--navy-900);
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.privacy-link {
  margin-top: 10px;
  padding: 3px 0;
  border: 0;
  color: #4f7084;
  background: transparent;
  font-size: 10px;
  text-align: left;
  text-decoration: underline;
  cursor: pointer;
}

.result-panel {
  color: white;
  border-color: var(--navy-800);
  background: var(--navy-900);
}

.result-panel .secondary-button {
  margin-top: 9px;
  border-color: rgba(255, 255, 255, 0.28);
  color: #e4eef2;
  background: rgba(255, 255, 255, 0.08);
}

.result-panel .panel-kicker {
  color: #7ea4b9;
}

.result-label {
  margin: 10px 0 0;
  color: #f1cb79;
  font-size: 13px;
  font-weight: 850;
  text-align: center;
}

.answer-reveal {
  margin: 6px 0 14px;
  color: white;
  font-family: var(--serif);
  font-size: 72px;
  font-weight: 700;
  line-height: 1.1;
  text-align: center;
}

.result-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  margin: 0 0 18px;
  padding: 13px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.result-stats div {
  text-align: center;
}

.result-stats div + div {
  border-left: 1px solid rgba(255, 255, 255, 0.12);
}

.result-stats dt {
  color: #88a3b3;
  font-size: 9px;
}

.result-stats dd {
  margin: 4px 0 0;
  font-size: 14px;
  font-weight: 800;
}

.feedback-box {
  margin-top: 15px;
  padding-top: 13px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
}

.feedback-box p {
  margin: 0 0 9px;
  color: #b8cbd5;
  font-size: 10px;
  text-align: center;
}

.feedback-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.feedback-actions button {
  min-height: 34px;
  padding: 5px 3px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: #d7e5eb;
  background: rgba(255, 255, 255, 0.07);
  font-size: 9px;
  cursor: pointer;
}

.feedback-actions button:hover,
.feedback-actions button:focus-visible,
.feedback-actions button.is-selected {
  border-color: #f1cb79;
  color: #071a2f;
  background: #f1cb79;
  outline: none;
}

#feedbackThanks {
  display: block;
  min-height: 16px;
  margin-top: 6px;
  color: #91bca7;
  font-size: 9px;
  text-align: center;
}

.tutorial-dialog,
.privacy-dialog {
  width: min(460px, calc(100% - 32px));
  padding: 0;
  border: 0;
  border-radius: 20px;
  color: var(--ink);
  background: white;
  box-shadow: 0 28px 80px rgba(3, 17, 31, 0.38);
}

.tutorial-dialog::backdrop,
.privacy-dialog::backdrop {
  background: rgba(2, 13, 25, 0.72);
  backdrop-filter: blur(6px);
}

.tutorial-dialog form,
.privacy-dialog form {
  position: relative;
  padding: 30px;
}

.tutorial-dialog h2,
.privacy-dialog h2 {
  max-width: 340px;
  margin: 0;
  color: var(--navy-900);
  font-family: var(--serif);
  font-size: 26px;
  line-height: 1.45;
}

.dialog-close {
  position: absolute;
  top: 16px;
  right: 16px;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 50%;
  color: #718795;
  background: var(--ice-100);
  font-size: 20px;
  cursor: pointer;
}

.tutorial-lead {
  margin: 13px 0 20px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.75;
}

.tutorial-lead strong {
  color: var(--red-600);
}

.tutorial-steps {
  padding: 16px;
  border-radius: 12px;
  background: var(--ice-50);
}

.tutorial-steps li {
  color: var(--navy-800);
}

.tutorial-steps li > span {
  border-color: var(--navy-700);
  color: white;
  background: var(--navy-700);
}

.start-button {
  margin-top: 22px;
}

.tutorial-note {
  display: block;
  margin-top: 11px;
  color: #8195a1;
  font-size: 9px;
  text-align: center;
}

.consent-option {
  display: grid;
  grid-template-columns: 20px 1fr;
  align-items: start;
  margin-top: 18px;
  padding: 12px;
  gap: 9px;
  border: 1px solid var(--ice-200);
  border-radius: 10px;
  background: var(--ice-50);
  cursor: pointer;
}

.consent-option input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--red-600);
}

.consent-option span {
  display: flex;
  flex-direction: column;
}

.consent-option strong {
  color: var(--navy-800);
  font-size: 11px;
}

.consent-option small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.55;
}

.consent-option.compact {
  margin: 17px 0;
}

.privacy-dialog p,
.privacy-dialog li {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.75;
}

.privacy-dialog ul {
  margin: 14px 0;
  padding-left: 20px;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  33% { transform: translateX(-5px); }
  66% { transform: translateX(5px); }
}

@media (max-width: 960px) {
  .game-layout {
    grid-template-columns: clamp(280px, calc((100dvh - 275px) * 0.6441), 500px) 310px;
  }

  .page-shell {
    width: min(100% - 24px, 1100px);
  }

  .panel {
    padding: 17px;
  }

  .keyboard-help {
    display: none;
  }

  .rink-footer {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .site-header {
    position: relative;
    min-height: 62px;
    padding: 9px 14px;
  }

  .brand-mark {
    width: 36px;
    height: 36px;
  }

  .brand-mark::before {
    width: 21px;
    height: 21px;
    border-width: 3px;
  }

  .brand-mark span {
    top: 7px;
    width: 16px;
    height: 4px;
  }

  .brand-copy strong {
    font-size: 16px;
  }

  .brand-copy small {
    display: none;
  }

  .mode-chip {
    display: none;
  }

  .text-button {
    font-size: 12px;
  }

  .page-shell {
    width: 100%;
    padding: 12px 12px 28px;
  }

  .intro-copy {
    display: block;
    margin: 0 4px 9px;
  }

  .intro-copy h1 {
    font-size: clamp(20px, 6.1vw, 24px);
  }

  .intro-rule {
    margin-top: 4px;
    font-size: 11px;
    text-align: left;
  }

  .game-layout {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .control-rail {
    position: static;
  }

  .rink-card {
    width: 100%;
    border-radius: 14px;
  }

  .rink-topline {
    min-height: 40px;
    padding: 7px 10px;
  }

  .rink-topline p {
    margin: 0 8px;
    font-size: 9px;
  }

  #gameCanvas {
    width: min(100%, calc((100dvh - 210px) * 0.6441));
  }

  .rink-footer {
    display: none;
  }

  .gesture-tip {
    min-width: 224px;
    padding: 11px 12px 11px 46px;
  }

  .gesture-tip small {
    font-size: 9px;
  }

  .gesture-line {
    left: 24px;
  }

  .control-rail {
    width: 100%;
    gap: 10px;
  }

  .panel {
    padding: 18px;
    border-radius: 14px;
    box-shadow: 0 12px 30px rgba(4, 24, 42, 0.08);
  }

  .question-panel {
    order: 1;
  }

  .strategy-panel {
    order: 3;
  }

  .player-record-panel {
    order: 4;
  }

  .result-panel {
    order: 2;
  }

  .answer-row { grid-template-columns: minmax(0, 1fr) auto; }
}

@media (max-width: 380px) {
  .tutorial-dialog form {
    padding: 25px 20px 22px;
  }

  .tutorial-dialog h2 {
    font-size: 23px;
  }

  .panel-heading {
    gap: 8px;
  }

  .panel h2 {
    font-size: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
