:root {
  color-scheme: light;
  --ink: #253331;
  --muted: #667572;
  --line: #dce9e4;
  --mint: #8edfc1;
  --mint-deep: #2f8f70;
  --deep: var(--mint-deep);
  --warn: #efb75d;
  --bad: #df7c74;
  --paper: #fffefa;
  --wash: #f2f8f5;
  --soft: #e8f4ef;
  --shadow: 0 18px 45px rgba(45, 92, 78, 0.12);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% 12%, rgba(142, 223, 193, 0.14), transparent 25%),
    linear-gradient(180deg, #ffffff 0%, #fbfffd 48%, #f6fbf8 100%);
  font-size: 16px;
  line-height: 1.8;
}
button, input { font: inherit; }
button { color: inherit; }
a { color: inherit; }
.site-header, .site-footer, .ball-drop-page {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}
.site-header, .site-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
}
.site-header { padding: 18px 0 8px; }
.site-logo {
  color: var(--mint-deep);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-decoration: none;
}
.site-nav, .site-footer {
  color: var(--muted);
  font-size: 0.92rem;
}
.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}
.site-nav a, .site-footer a { text-decoration: none; }
.site-nav a:hover, .site-footer a:hover { color: var(--mint-deep); }
.ball-drop-page { padding: 10px 0 48px; }
.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}
.breadcrumb a { color: #315d68; }
.local-nav {
  display: flex;
  gap: 9px;
  align-items: center;
  margin-bottom: 22px;
  color: var(--muted);
  font-size: 12px;
}
.local-nav a { text-decoration: none; }
.local-nav a:hover { color: var(--mint-deep); text-decoration: underline; }
.series-label {
  margin: 0 0 10px;
  color: var(--mint-deep);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.1em;
}

.page-intro { margin-bottom: 22px; }
.eyebrow, .level-label {
  margin: 0 0 4px;
  color: var(--deep);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: .06em;
}
h1, h2, p { margin-top: 0; }
h1 {
  margin-bottom: 5px;
  color: #182321;
  font-size: clamp(26px, 4vw, 36px);
  line-height: 1.25;
}
.lead {
  max-width: 690px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 14px;
}
.game-panel, .how-to-play {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
  box-shadow: 0 5px 18px rgb(37 51 49 / 4%);
}
.game-panel { padding: 20px; }
.game-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  margin-bottom: 13px;
}
.level-label { margin-bottom: 1px; font-size: 10px; }
.game-heading h2 { margin: 0; font-size: 19px; line-height: 1.3; }
.game-screen {
  position: relative;
  overflow: hidden;
  border: 1px solid #d2e3dc;
  border-radius: 9px;
  background: #e9f5ef;
}
#scene {
  position: relative;
  z-index: 1;
  display: block;
  width: 100%;
  height: clamp(540px, 55vw, 620px);
}
.scene-options {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 10px;
}
.scene-options label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
}
.scene-options select {
  min-width: 92px;
  height: 36px;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.scene-options select:focus-visible {
  outline: 3px solid #70c5a5;
  outline-offset: 2px;
}
.screen-level-picker {
  position: absolute;
  z-index: 4;
  top: calc(8px + env(safe-area-inset-top));
  left: calc(8px + env(safe-area-inset-left));
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 3px 5px 3px 8px;
  border: 1px solid #d2e3dc;
  border-radius: 8px;
  color: var(--ink);
  background: rgb(242 248 245 / 96%);
  box-shadow: 0 3px 12px rgb(37 51 49 / 13%);
  font-size: 11px;
  font-weight: 800;
  line-height: 1.2;
  pointer-events: auto;
}
.screen-level-picker span { white-space: nowrap; }
.screen-level-picker select {
  min-width: 48px;
  height: 36px;
  padding: 2px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  cursor: pointer;
}
.screen-level-picker select:focus-visible {
  outline: 3px solid #70c5a5;
  outline-offset: 2px;
}
.screen-level-picker select:disabled { opacity: .55; }
.screen-height-label {
  position: absolute;
  z-index: 4;
  top: calc(58px + env(safe-area-inset-top));
  left: 50%;
  max-width: calc(100% - 16px - env(safe-area-inset-left) - env(safe-area-inset-right));
  transform: translateX(-50%);
  padding: 6px 11px;
  border: 1px solid #d2e3dc;
  border-radius: 8px;
  color: var(--ink);
  background: rgb(242 248 245 / 96%);
  box-shadow: 0 3px 12px rgb(37 51 49 / 13%);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
}
.screen-caption {
  margin: 9px 0 12px;
  color: var(--muted);
  font-size: 11px;
}
.status-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f2f8f5;
}
.status-message { margin: 0; font-size: 13px; font-weight: 700; }
.screen-controls {
  position: absolute;
  z-index: 3;
  inset: 0;
  pointer-events: none;
}
.screen-control-grid { display: contents; }
.screen-control {
  position: absolute;
  bottom: calc(8px + env(safe-area-inset-bottom));
  width: 112px;
  min-width: 112px;
  min-inline-size: 112px;
  margin: 0;
  padding: 5px 7px 7px;
  border: 1px solid #d2e3dc;
  border-radius: 10px;
  background: rgb(242 248 245 / 96%);
  box-shadow: 0 3px 12px rgb(37 51 49 / 13%);
  pointer-events: auto;
}
#ball-controls { left: calc(6px + env(safe-area-inset-left)); }
#view-controls { right: calc(6px + env(safe-area-inset-right)); }
.screen-control legend {
  display: block;
  margin: 0 auto 2px;
  padding: 0 3px;
  font-size: 11px;
  font-weight: 800;
  line-height: 19px;
  text-align: center;
  white-space: nowrap;
}
.direction-pad {
  display: grid;
  grid-template-columns: repeat(2, 44px);
  grid-template-rows: repeat(3, 44px);
  justify-content: center;
  gap: 8px;
  width: 96px;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.direction-button.direction-up,
.direction-button.direction-down { grid-column: 1 / span 2; justify-self: center; }
.direction-button.direction-up { grid-row: 1; }
.direction-button.direction-left { grid-column: 1; grid-row: 2; }
.direction-button.direction-right { grid-column: 2; grid-row: 2; }
.direction-button.direction-down { grid-row: 3; }
.direction-button {
  width: 44px;
  min-width: 44px;
  height: 44px;
  min-height: 44px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fcfa;
  font-size: 20px;
  font-weight: 700;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.direction-button:hover { border-color: var(--deep); background: #eef8f3; }
.direction-button:active { color: #fff; border-color: var(--deep); background: var(--deep); }
.direction-button:focus-visible, .button:focus-visible, a:focus-visible {
  outline: 3px solid #70c5a5;
  outline-offset: 2px;
}
.screen-drop-button {
  position: absolute;
  left: 50%;
  bottom: calc(8px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  width: min(150px, calc(100% - 32px));
  min-height: 44px;
  padding: 7px 10px;
  pointer-events: auto;
}
#screen-actions {
  position: absolute;
  left: 50%;
  bottom: calc(58px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: min(150px, calc(100% - 32px));
  pointer-events: auto;
}
#screen-actions .button {
  flex: none;
  width: 100%;
  min-width: 0;
  min-height: 44px;
  padding: 6px 4px;
  font-size: 10px;
  line-height: 1.2;
  white-space: nowrap;
}
.screen-controls.is-result .screen-control-grid,
.screen-controls.is-result .screen-drop-button {
  display: none;
}
.screen-controls.is-result #screen-actions {
  top: calc(50% - 24px);
  bottom: auto;
  transform: translateX(-50%);
  width: min(260px, calc(100% - 32px));
  gap: 8px;
}
.screen-controls.is-result #screen-actions .button {
  min-height: 48px;
  padding: 8px 12px;
  font-size: 14px;
}
.screen-controls.is-result:not(.is-miss) #next-button {
  order: -1;
}
.screen-controls.is-miss #screen-actions {
  top: calc(50% - 32px);
}
.screen-controls.is-miss #screen-actions #retry-button {
  min-height: 64px;
  border-color: var(--deep);
  background: var(--deep);
  color: #fff;
  font-size: 18px;
  box-shadow: 0 6px 16px rgb(22 66 50 / 25%);
}
.screen-controls.is-miss #screen-actions #retry-button:hover:not(:disabled) {
  background: #26785e;
}
.screen-fullscreen-button {
  position: absolute;
  z-index: 4;
  top: calc(8px + env(safe-area-inset-top));
  right: calc(8px + env(safe-area-inset-right));
  min-width: 44px;
  min-height: 44px;
  padding: 6px 10px;
  pointer-events: auto;
}
.button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.button-primary { color: #fff; background: var(--deep); }
.button-primary:hover:not(:disabled) { background: #26785e; }
.button-secondary { border-color: var(--line); background: #fff; }
.button-secondary:hover:not(:disabled) { border-color: var(--deep); background: #f6fbf8; }
.button:disabled, .direction-button:disabled { opacity: .55; cursor: not-allowed; }
[hidden] { display: none !important; }
.action-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 14px;
}
.drop-help { margin: 0; color: var(--muted); font-size: 11px; }
.action-buttons { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.button {
  min-height: 44px;
  padding: 8px 15px;
  border: 1px solid transparent;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}
.button-primary { color: #fff; background: var(--deep); }
.button-primary:hover:not(:disabled) { background: #26785e; }
.button-secondary { border-color: var(--line); background: #fff; }
.button-secondary:hover:not(:disabled) { border-color: var(--deep); background: #f6fbf8; }
.button:disabled, .direction-button:disabled { opacity: .55; cursor: not-allowed; }
[hidden] { display: none !important; }
.keyboard-help { margin: 11px 0 0; color: var(--muted); font-size: 10px; text-align: right; }
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 1px 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fbfdfc;
  font: 600 10px ui-monospace, monospace;
  text-align: center;
}
.how-to-play { margin-top: 18px; padding: 18px 20px; }
.how-to-play h2 { margin: 0 0 9px; font-size: 18px; }
.how-to-play ol { margin: 0; padding-left: 22px; }
.how-to-play li { margin: 5px 0; color: var(--muted); font-size: 12px; }
.how-to-play li strong { margin-right: 5px; color: var(--ink); }
.rule-note {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--mint);
  background: #f6fbf8;
  color: var(--muted);
  font-size: 11px;
}

.related-games {
  margin-top: 18px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--paper);
}
.related-games h2 { margin: 0 0 8px; font-size: 18px; }
.related-games p { margin: 0; color: var(--muted); font-size: 13px; }
.related-games a { text-decoration: underline; text-underline-offset: 3px; }
.game-comment-section { width: 100%; margin: 22px auto 32px; }
.game-comment-note { color: var(--muted); font-size: 0.85rem; }
.app-comment-form { min-width: 0; margin: 0; padding: 0; border: 0; }
.app-comment-form :disabled { cursor: not-allowed; }

@media (max-width: 640px) {
  .site-header, .site-footer, .ball-drop-page {
    width: min(100% - 24px, 1080px);
  }
  .site-header, .site-footer {
    align-items: flex-start;
    flex-direction: column;
    gap: 10px;
  }
  .site-nav { gap: 8px 14px; }
  .site-footer { padding: 28px 0 32px; }
  .ball-drop-page { padding-top: 12px; padding-bottom: 30px; }
  .local-nav { margin-bottom: 16px; }
  .page-intro { margin-bottom: 16px; }
  .lead { font-size: 13px; }
  .game-panel { padding: 12px; border-radius: 10px; }
  .game-heading { display: block; margin-bottom: 9px; }
  .game-heading h2 { font-size: 16px; }
  #scene { height: clamp(540px, 145vw, 580px); }
  .status-row { display: block; padding: 9px 10px; }
  .screen-control {
    width: 96px;
    min-width: 96px;
    min-inline-size: 96px;
    padding: 4px 0 6px;
  }
  .screen-control legend { font-size: 10px; }
  .screen-drop-button {
    width: 44px;
    min-width: 44px;
    padding: 6px 0;
    font-size: 10px;
  }
  #screen-actions { width: 44px; }
  #screen-actions .button { padding: 6px 0; font-size: 9px; }
  .action-row { display: block; margin-top: 11px; }
  .drop-help { margin-bottom: 7px; }
  .action-buttons { justify-content: stretch; }
  .action-buttons .button { flex: 1 1 auto; padding-inline: 10px; }
  .keyboard-help { text-align: left; }
  .how-to-play { padding: 15px; }
  .related-games { padding: 15px; }
}
@media (max-width: 340px) {
  .game-panel { padding: 8px; }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body.game-viewport-open { overflow: hidden; }
.game-screen:fullscreen,
.game-screen.is-viewport {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  border: 0;
  border-radius: 0;
}
.game-screen.is-viewport {
  position: fixed;
  inset: 0;
  z-index: 1000;
}
.game-screen:fullscreen #scene,
.game-screen.is-viewport #scene {
  width: 100%;
  height: 100%;
}
