/* =========================================================
   style.css — レイアウトと HUD
   ========================================================= */

:root {
  --bg:        #12141c;
  --bg2:       #1b1f2b;
  --panel:     #232838;
  --line:      #39415a;
  --text:      #e6eaf5;
  --dim:       #99a2bd;
  --accent:    #ffd94a;
  --ok:        #5fd47a;
  --bad:       #ff5a5a;
  --font: "DotGothic16", "Hiragino Kaku Gothic ProN", "Yu Gothic",
          "Noto Sans JP", "MS PGothic", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
  -webkit-font-smoothing: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px;
}

/* ---------------- HUD ---------------- */
#hud {
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
  background: linear-gradient(180deg, var(--bg2), #151824);
  border: 2px solid var(--line);
  border-radius: 4px;
  padding: 6px 14px;
  min-height: 44px;
  width: min(100%, 1024px);
}

.hud-group {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.hud-group.right { margin-left: auto; align-items: center; }

.hud-label {
  font-size: 11px;
  color: var(--dim);
  letter-spacing: 0.06em;
}
.hud-value {
  font-size: 15px;
  color: var(--text);
  font-variant-numeric: tabular-nums;
}
.hud-value.big {
  font-size: 20px;
  color: var(--accent);
  letter-spacing: 0.08em;
}
.hud-mini {
  font-size: 10px;
  color: var(--dim);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 2px 6px;
}
.hud-mini.off { color: #6a7290; }

/* HUD のポーズボタン */
.hud-btn {
  font-family: var(--font);
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text);
  background: #232839;
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 4px 10px;
  cursor: pointer;
  min-width: 84px;
  transition: background 0.12s linear, color 0.12s linear, border-color 0.12s linear;
}
.hud-btn:hover:not(:disabled) { background: #2e3549; border-color: #55608a; }
.hud-btn:active:not(:disabled) { transform: translateY(1px); }
.hud-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
/* ポーズ中は「再開」として目立たせる */
.hud-btn.on {
  color: #1a1d28;
  background: var(--accent);
  border-color: #b89a20;
}
.hud-btn:disabled { opacity: 0.35; cursor: default; }

@media (prefers-reduced-motion: reduce) {
  .hud-btn { transition: none; }
  .hud-btn:active:not(:disabled) { transform: none; }
}

.hearts {
  font-size: 18px;
  color: var(--bad);
  letter-spacing: 2px;
}
.hearts.low { animation: blink 0.7s steps(2, end) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.bar {
  display: inline-block;
  width: 80px;
  height: 8px;
  background: #10131c;
  border: 1px solid var(--line);
  border-radius: 2px;
  overflow: hidden;
}
.bar > i {
  display: block;
  height: 100%;
  width: 0%;
  background: var(--ok);
  transition: width 0.25s linear, background 0.25s linear;
}
.bar > i.danger { background: var(--bad); }

/* ---------------- 結果レポート ---------------- */
.panel-report {
  max-width: 680px;
  max-height: min(92vh, 96%);
  padding: 16px 22px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.panel-report h2.over { margin-bottom: 2px; }
.panel-report .score-line { margin: 2px 0; }
.panel-report .stats { margin: 6px 0 2px; }
.report {
  flex: 1 1 auto;
  min-height: 0;
  margin: 8px 0 10px;
  overflow-y: auto;
  overflow-x: auto;
  text-align: left;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  padding: 10px 8px 10px 0;
}
.report-title {
  font-size: 11px;
  letter-spacing: 0.12em;
  color: var(--dim);
  margin: 0 0 8px;
}

/* --- 棒グラフ --- */
.chart {
  display: flex;
  align-items: flex-end;
  gap: 5px;
  height: 78px;
  padding: 13px 2px 0;
  margin-bottom: 3px;
}
.chart-col {
  flex: 1 1 0;
  min-width: 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
  position: relative;
}
.chart-bar {
  width: 100%;
  background: linear-gradient(180deg, var(--accent), #c79a12);
  border: 1px solid #7d6209;
  border-radius: 2px 2px 0 0;
  min-height: 2px;
}
.chart-col.best .chart-bar { background: linear-gradient(180deg, #7ef09a, var(--ok)); border-color: #2f7a45; }
.chart-val {
  position: absolute;
  top: -13px;
  font-size: 9px;
  color: var(--text);
  white-space: nowrap;
}
.chart-labels {
  display: flex;
  gap: 6px;
  padding: 0 2px;
}
.chart-labels span {
  flex: 1 1 0;
  min-width: 26px;
  text-align: center;
  font-size: 9px;
  color: var(--dim);
  white-space: nowrap;
}

/* --- 表 --- */
.report table {
  width: 100%;
  border-collapse: collapse;
  font-size: 11px;
  font-variant-numeric: tabular-nums;
  margin-top: 10px;
}
.report th,
.report td {
  padding: 4px 6px;
  border-bottom: 1px solid #2b3149;
  text-align: right;
  white-space: nowrap;
}
.report th:first-child,
.report td:first-child { text-align: left; }
.report thead th {
  color: var(--dim);
  font-weight: normal;
  font-size: 10px;
  letter-spacing: 0.04em;
  border-bottom: 1px solid var(--line);
  position: sticky;
  top: 0;
  background: var(--panel);
}
.report tbody tr:last-child td { border-bottom: 0; }
.report tfoot td {
  border-top: 1px solid var(--line);
  border-bottom: 0;
  color: var(--accent);
  padding-top: 6px;
}
.report .bad-n { color: var(--bad); }
.panel-report .btn { margin-top: 4px; }
.panel-report .mini { margin-top: 6px; }
.report .zero { color: #5b6382; }

/* ---------------- 中央アナウンス ---------------- */
.announce {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  z-index: 9;              /* オーバーレイ(10)より下。ポーズ中は隠れる */
  pointer-events: none;    /* クリックを通す */
  text-align: center;
}
.announce.hidden { display: none; }

.announce .an-logo,
.announce .an-text {
  font-family: var(--font);
  color: #ffc21f;
  -webkit-text-stroke: 4px #2f3a52;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 rgba(20, 24, 38, 0.55);
  line-height: 1.1;
}
.announce .an-logo {
  font-size: clamp(40px, 8vw, 76px);
  letter-spacing: 0.08em;
}
.announce .an-text {
  font-size: clamp(20px, 3.6vw, 34px);
  letter-spacing: 0.04em;
  color: #ffffff;
  -webkit-text-stroke: 3px #2f3a52;
}

/* 出て、少し待って、消える */
.announce.play .an-logo { animation: announce-in 2.6s ease-out both; }
.announce.play .an-text { animation: announce-in 2.6s ease-out 0.12s both; }

@keyframes announce-in {
   0%  { opacity: 0; transform: scale(0.6); }
  12%  { opacity: 1; transform: scale(1.12); }
  20%  { transform: scale(1); }
  78%  { opacity: 1; transform: scale(1); }
 100%  { opacity: 0; transform: scale(1.06); }
}

@media (prefers-reduced-motion: reduce) {
  .announce.play .an-logo,
  .announce.play .an-text { animation: announce-fade 2.6s linear both; }
  @keyframes announce-fade { 0%,100% { opacity: 0; } 10%,80% { opacity: 1; } }
}

/* ---------------- ステージ ---------------- */
#stage {
  position: relative;
  line-height: 0;
}

#screen {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #4a4f5c;
  border: 3px solid var(--line);
  border-radius: 3px;
  cursor: crosshair;
  touch-action: none;
}

/* ---------------- オーバーレイ ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(10, 12, 20, 0.86);
  line-height: 1.6;
  text-align: center;
  z-index: 10;
}
.overlay.hidden { display: none; }

/* ---------------- 明るいタイトル / あそびかた ---------------- */
.overlay.bright {
  background: linear-gradient(180deg,
              #7fc9f0 0%, #a8ddf7 38%, #d9f0ff 62%, #ffeab4 100%);
  overflow: hidden;
  padding: 12px;
}

/* 空の飾り（雲と太陽） */
.sky-deco { position: absolute; inset: 0; pointer-events: none; }
.sky-deco .cloud {
  position: absolute;
  display: block;
  background: rgba(255, 255, 255, 0.92);
  border-radius: 999px;
  box-shadow: 22px 6px 0 -4px rgba(255,255,255,0.92),
             -22px 8px 0 -6px rgba(255,255,255,0.92);
}
.sky-deco .c1 { width: 64px; height: 22px; top: 9%;  left: 12%; animation: drift 34s linear infinite; }
.sky-deco .c2 { width: 48px; height: 18px; top: 22%; left: 68%; animation: drift 46s linear infinite; }
.sky-deco .c3 { width: 80px; height: 26px; top: 5%;  left: 44%; animation: drift 58s linear infinite; }
@keyframes drift { from { transform: translateX(-14px); } to { transform: translateX(14px); } }

.sky-deco .sun {
  position: absolute;
  top: 6%; right: 9%;
  width: 54px; height: 54px;
  border-radius: 50%;
  background: #ffd94a;
  box-shadow: 0 0 0 10px rgba(255, 217, 74, 0.28);
}

.title-card, .help-card {
  position: relative;
  z-index: 1;
  background: #fffdf3;
  border: 4px solid #2f3a52;
  border-radius: 10px;
  box-shadow: 0 8px 0 rgba(47, 58, 82, 0.35), 0 0 0 4px rgba(255,255,255,0.5);
  color: #2f3a52;
  text-align: center;
}

.title-card {
  padding: 18px 30px 20px;
  width: min(470px, 100%);
}

.version-tag {
  position: absolute;
  top: 10px;
  right: 12px;
  padding: 3px 9px;
  border-radius: 999px;
  background: #2f3a52;
  color: #ffd94a;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.title-badge {
  margin: 0;
  font-size: 13px;
  letter-spacing: 0.28em;
  color: #e0574a;
}
.title-logo {
  margin: 2px 0 0;
  font-size: 52px;
  line-height: 1;
  letter-spacing: 0.06em;
  color: #ffc21f;
  -webkit-text-stroke: 3px #2f3a52;
  paint-order: stroke fill;
  text-shadow: 0 5px 0 #2f3a52;
}
.title-sub {
  margin: 8px 0 0;
  font-size: 19px;
  letter-spacing: 0.34em;
  color: #2f3a52;
  font-weight: bold;
}

#title-art {
  display: block;
  margin: 12px auto 4px;
  width: 336px;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  border: 3px solid #2f3a52;
  border-radius: 6px;
}

.title-lead { margin: 10px 0 0; font-size: 13px; color: #4a566f; line-height: 1.7; }
.title-lead-sub { font-size: 11.5px; color: #7b869e; }

.title-buttons {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 16px;
}

.title-foot {
  margin: 14px 0 0;
  font-size: 11px;
  color: #7b869e;
  letter-spacing: 0.04em;
}
.title-foot b { color: #2f3a52; }

/* --- ボタン（.btn より後に定義された .btn に負けないよう二重クラスで指定） --- */
.btn.btn-lg {
  font-size: 17px;
  padding: 13px 26px;
  min-width: 190px;
  border-radius: 8px;
  margin-top: 0;
}
.btn.btn-start {
  background: #46c26a;
  color: #ffffff;
  border-bottom: 5px solid #2f8d4b;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}
.btn.btn-help {
  background: #4aa8f0;
  color: #ffffff;
  border-bottom: 5px solid #2c76b3;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.25);
}

/* --- あそびかた --- */
.help-card {
  display: flex;
  flex-direction: column;
  padding: 18px 24px 18px;
  width: min(620px, 100%);
  max-height: calc(100% - 24px);
  text-align: left;
}
.help-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding-right: 6px;
  margin-bottom: 12px;
}
.help-title {
  margin: 0 0 14px;
  font-size: 24px;
  text-align: center;
  letter-spacing: 0.2em;
  color: #2f3a52;
}
.help-title::after {
  content: '';
  display: block;
  width: 72px; height: 4px;
  margin: 8px auto 0;
  background: #ffc21f;
  border-radius: 2px;
}
.help-sec { margin: 0 0 16px; }
.help-sec h3 {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 6px;
  font-size: 15px;
  color: #2f3a52;
}
.help-sec h3 .num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #2f3a52;
  color: #ffc21f;
  font-size: 13px;
}
.help-sec p, .help-sec li { font-size: 12.5px; line-height: 1.75; color: #4a566f; }
.help-sec b { color: #2f3a52; }
.help-sec b.ok-t  { color: #2f8d4b; }
.help-sec b.bad-t { color: #d63b3b; }
.help-sec ul { margin: 4px 0 0; padding-left: 20px; }
.help-sec li { margin: 3px 0; }
.help-sec .note {
  margin: 6px 0 0;
  padding: 7px 10px;
  background: #f1f6ff;
  border-left: 4px solid #4aa8f0;
  border-radius: 3px;
  font-size: 12px;
}

.keys {
  width: 100%;
  border-collapse: collapse;
  font-size: 12.5px;
}
.keys td {
  padding: 5px 8px;
  border-bottom: 1px dashed #d5dcea;
  color: #4a566f;
  vertical-align: middle;
}
.keys td:first-child { width: 44%; white-space: nowrap; color: #2f3a52; }

.help-card .crew { margin: 4px 0 8px; }
.chip {
  display: inline-block;
  margin-right: 8px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 12px;
  background: #eef2f9;
  border: 1px solid #d5dcea;
  color: #2f3a52;
}
.chip.you  { color: #7a8a13; }
.chip.cpu1 { color: #c26612; }

.help-card .btn-lg { display: block; margin: 0 auto; flex: 0 0 auto; }

/* 明るい画面の中の kbd は反転させる */
.bright kbd {
  background: #fffdf3;
  color: #2f3a52;
  border-color: #b9c3d6;
}

.panel {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 6px;
  padding: 22px 30px;
  max-width: 560px;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.4);
}
.panel.small { padding: 16px 34px; }

.panel h1 {
  margin: 0 0 2px;
  font-size: 22px;
  letter-spacing: 0.04em;
}
.panel h1 .brand { color: var(--accent); }
.panel h2 {
  margin: 0 0 12px;
  font-size: 17px;
  color: var(--dim);
  letter-spacing: 0.2em;
}
.panel h2.over { color: var(--bad); letter-spacing: 0.08em; }

.lead { font-size: 13px; margin: 10px 0; }
.tip  { font-size: 12px; color: var(--dim); margin: 12px 0 4px; }
.mini { font-size: 11px; color: var(--dim); margin: 8px 0 0; }

.howto {
  list-style: none;
  margin: 12px auto;
  padding: 12px 14px;
  text-align: left;
  display: inline-block;
  font-size: 12px;
  background: #1b1f2b;
  border: 1px solid var(--line);
  border-radius: 4px;
}
.howto li { margin: 4px 0; }

.score-line { font-size: 15px; margin: 6px 0; }
.score-line b { color: var(--accent); font-size: 24px; letter-spacing: 0.08em; }
.stats { font-size: 12px; color: var(--dim); margin: 10px 0 4px; }
.stats b { color: var(--text); }

.btn {
  margin-top: 14px;
  font-family: var(--font);
  font-size: 14px;
  color: #1a1d28;
  background: var(--accent);
  border: 0;
  border-bottom: 3px solid #b89a20;
  border-radius: 4px;
  padding: 10px 26px;
  cursor: pointer;
  letter-spacing: 0.06em;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); border-bottom-width: 1px; }

kbd {
  display: inline-block;
  font-family: var(--font);
  font-size: 11px;
  background: #10131c;
  color: var(--text);
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 3px;
  padding: 1px 5px;
  margin: 0 1px;
}

/* ---------------- フッター ---------------- */
#hint {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
  font-size: 11px;
  color: var(--dim);
  line-height: 1.8;
}

@media (max-width: 720px) {
  .hud-group.right { margin-left: 0; }
  #hud { gap: 10px; font-size: 11px; }
  #hint { display: none; }
}
