:root {
  --bg: #0f1622;
  --bg-alt: #18243a;
  --accent: #e4b34c;
  --accent-dark: #b4862d;
  --red: #d33f3f;
  --green: #1aab5e;
  --blue: #5fb5ff;
  --text: #f3efe6;
  --text-dim: #9aa7bd;
  --plate-shadow: rgba(0, 0, 0, 0.4);
  --font-sans: "Hiragino Sans", "Yu Gothic", "Meiryo", system-ui, sans-serif;
  --font-display: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  --kb-bg: #1a212e;
  --kb-key-bg: #2b3a55;
  --kb-key-bg-mod: #3f4a5e;
  --kb-key-text: #f3efe6;
  --kb-key-text-dim: #aab3c5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: linear-gradient(180deg, #0a0f1a 0%, #1a2740 100%);
  color: var(--text);
  font-family: var(--font-sans);
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
  touch-action: pan-y;
}

#app {
  position: relative;
  width: 100%;
  /* 100vh は旧ブラウザ用フォールバック。100dvh が後勝ちで優先される。
     iOS Safari の URL バー出現時は dvh の方が小さく、可視領域に
     ぴったり一致する。 */
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ヘッダー */
.kt-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 16px;
  background: rgba(0, 0, 0, 0.3);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  z-index: 5;
}

.kt-title {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.1em;
  margin: 0;
}

.kt-title .kanji {
  color: var(--accent);
}

.kt-stats {
  display: flex;
  gap: 10px;
  font-size: 12px;
  color: var(--text-dim);
  align-items: center;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.kt-stat-value {
  color: var(--text);
  font-weight: 600;
  font-size: 14px;
  margin-left: 4px;
}

.kt-combo-stat {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 700;
  letter-spacing: 0.06em;
}
.kt-combo-stat.active {
  background: var(--accent);
  color: #14181f;
  box-shadow: 0 0 14px rgba(228, 179, 76, 0.5);
  animation: combo-pulse 600ms ease-out;
}

.kt-mode-badge {
  padding: 3px 8px;
  border-radius: 4px;
  background: linear-gradient(135deg, #b4304a 0%, #d33f3f 100%);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  box-shadow: 0 0 10px rgba(211, 63, 63, 0.4);
}
.kt-mode-badge[hidden] {
  display: none;
}
@keyframes combo-pulse {
  0% { transform: scale(0.85); }
  60% { transform: scale(1.12); }
  100% { transform: scale(1); }
}

/* メインステージ */
.kt-stage {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
}

/* コンベア */
.kt-conveyor {
  position: relative;
  flex: 1;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.25) 60%, rgba(0, 0, 0, 0.4) 100%);
  overflow: hidden;
  min-height: 160px;
}

.kt-conveyor::before,
.kt-conveyor::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  height: 18px;
  background: linear-gradient(90deg, #6c4f2c 0%, #8b6939 50%, #6c4f2c 100%);
  box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
}
.kt-conveyor::before {
  top: 28%;
}
.kt-conveyor::after {
  bottom: 30%;
  background: linear-gradient(90deg, #4d3617 0%, #7a5a2f 50%, #4d3617 100%);
}

/* === 寿司皿 === */
.kt-plate {
  position: absolute;
  width: 160px;
  height: 100px;
  /* IME が開いてコンベアが縮んでも皿が画面外に追いやられないよう中央寄せ。
     横位置は JS で left を更新する。 */
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  pointer-events: none;
  --price-color: #16a34a;
  --neta-color: #a93232;
  --neta-accent: #7c1d1d;
}

.kt-plate-band {
  position: absolute;
  bottom: 0;
  left: 6px;
  right: 6px;
  height: 28px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #fafafa 0%, #d8d8d8 65%, #888 100%);
  box-shadow: 0 8px 16px var(--plate-shadow);
}
.kt-plate-band::before {
  content: "";
  position: absolute;
  inset: 2px 4px;
  border-radius: 50%;
  border: 3px solid var(--price-color);
  opacity: 0.55;
}

.kt-plate.miss .kt-plate-band {
  filter: grayscale(0.8) brightness(0.7);
}
.kt-plate.eaten {
  animation: kt-plate-eaten 360ms ease-out forwards;
}
@keyframes kt-plate-eaten {
  from {
    transform: translateY(-50%) scale(1);
    opacity: 1;
  }
  to {
    transform: translateY(calc(-50% - 50px)) scale(1.2);
    opacity: 0;
  }
}

/* 寿司ベース */
.kt-sushi {
  position: relative;
  width: 110px;
  height: 64px;
  margin-bottom: 18px;
  z-index: 2;
}

/* ご飯部分(共通) */
.kt-rice {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 86px;
  height: 28px;
  background: linear-gradient(180deg, #fff 0%, #f1ebd9 100%);
  border-radius: 28px 28px 12px 12px / 24px 24px 12px 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.18) inset;
}

/* slab: まぐろ・サーモン・いか・あなご */
.kt-neta-slab {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) rotate(-1deg);
  width: 96px;
  height: 22px;
  background: var(--neta-color);
  border-radius: 18px 18px 10px 10px / 14px 14px 10px 10px;
  box-shadow: 0 2px 0 var(--neta-accent) inset, 0 3px 6px rgba(0, 0, 0, 0.25);
}
.kt-neta-slab::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 8px;
  right: 8px;
  height: 4px;
  background: rgba(255, 255, 255, 0.35);
  border-radius: 999px;
}

/* たまご: block */
.kt-neta-block {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 92px;
  height: 28px;
  background: linear-gradient(180deg, #fde186 0%, var(--neta-color) 60%, var(--neta-accent) 100%);
  border-radius: 6px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
}
.kt-nori-band {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: 24px;
  height: 38px;
  background: linear-gradient(180deg, #1d2b1c 0%, #2c3f24 100%);
  border-radius: 2px;
  z-index: 3;
}

/* えび: ebi */
.kt-neta-ebi {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 96px;
  height: 22px;
  background: linear-gradient(180deg, #f8b8ad 0%, var(--neta-color) 60%, var(--neta-accent) 100%);
  border-radius: 18px 18px 8px 8px;
  box-shadow: 0 3px 6px rgba(0, 0, 0, 0.22);
}
.kt-ebi-stripe {
  position: absolute;
  top: 4px;
  width: 14px;
  height: 8px;
  background: var(--neta-accent);
  border-radius: 999px;
  opacity: 0.55;
}
.kt-ebi-stripe:nth-child(1) { left: 18px; }
.kt-ebi-stripe:nth-child(2) { left: 46px; }
.kt-ebi-tail {
  position: absolute;
  right: -8px;
  bottom: 4px;
  width: 16px;
  height: 14px;
  background: var(--neta-accent);
  clip-path: polygon(0 50%, 100% 0, 80% 50%, 100% 100%);
}

/* いくら: gunkan-like with grains */
.kt-nori {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 92px;
  height: 32px;
  background: linear-gradient(180deg, #1d2b1c 0%, #2c3f24 100%);
  border-radius: 12px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.25);
}
.kt-ikura-grains {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 80px;
  height: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  justify-content: center;
}
.kt-ikura-grains span {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, #ffd394 0%, #ff8a2c 50%, #d4621a 100%);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* うに: gunkan with golden top */
.kt-gunkan-top {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 80px;
  height: 14px;
  background: linear-gradient(180deg, #ffd87b 0%, var(--neta-color) 50%, var(--neta-accent) 100%);
  border-radius: 14px 14px 4px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* 巻物: maki */
.kt-shape-maki .kt-rice { display: none; }
.kt-maki-outer {
  position: absolute;
  left: 50%;
  bottom: 4px;
  transform: translateX(-50%);
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(180deg, #1d2b1c 0%, #2c3f24 100%);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}
.kt-maki-rice {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #fff 0%, #f1ebd9 80%);
}
.kt-maki-filling {
  position: absolute;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, var(--neta-color) 0%, var(--neta-accent) 100%);
}

/* お皿のキャラ名ラベル */
.kt-sushi-label {
  position: absolute;
  top: -22px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 18px;
  color: #14181f;
  background: rgba(255, 255, 255, 0.92);
  padding: 2px 8px;
  border-radius: 4px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  white-space: nowrap;
  letter-spacing: 0.04em;
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* アクティブな注文表示 */
.kt-order {
  position: relative;
  z-index: 4;
  margin: 0 auto;
  padding: 14px 16px 10px;
  width: 100%;
  max-width: 720px;
  background: rgba(8, 13, 22, 0.85);
  border-top: 2px solid rgba(228, 179, 76, 0.35);
  box-shadow: 0 -10px 24px rgba(0, 0, 0, 0.4);
}

.kt-order-display {
  font-family: var(--font-display);
  font-size: clamp(26px, 5.5vw, 40px);
  text-align: center;
  letter-spacing: 0.06em;
  color: var(--accent);
  margin: 0 0 4px;
}

.kt-order-kana {
  font-size: clamp(18px, 4vw, 26px);
  text-align: center;
  color: var(--text);
  font-weight: 600;
  letter-spacing: 0.08em;
}

.kt-order-kana .typed {
  color: var(--green);
}
.kt-order-kana .next {
  color: var(--accent);
  background: rgba(228, 179, 76, 0.15);
  border-radius: 4px;
  padding: 0 2px;
}
.kt-order-kana .pending {
  color: var(--text-dim);
}

.kt-order-romaji {
  margin-top: 6px;
  font-family: "Menlo", "Consolas", monospace;
  font-size: clamp(13px, 2.6vw, 17px);
  text-align: center;
  letter-spacing: 0.1em;
}
.kt-order-romaji .typed {
  color: var(--green);
}
.kt-order-romaji .pending {
  color: var(--text-dim);
}

.kt-mobile .kt-order-romaji {
  display: none;
}

/* ハードモード: ふりがな / ローマ字を伏せ、文字数だけ示す */
.kt-hard .kt-order-kana .kt-mask {
  display: inline-block;
  width: 0.7em;
  height: 0.7em;
  margin: 0 3px;
  border-radius: 50%;
  vertical-align: middle;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
}
.kt-hard .kt-order-kana .kt-mask.typed {
  background: var(--green);
  border-color: var(--green);
  box-shadow: 0 0 6px rgba(26, 171, 94, 0.5);
}
.kt-hard .kt-order-kana .kt-mask.next {
  background: var(--accent);
  border-color: var(--accent);
  box-shadow: 0 0 8px rgba(228, 179, 76, 0.6);
}
.kt-hard .kt-order-romaji {
  display: none !important;
}

.kt-order-meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 4px;
}
.kt-order-meta .price {
  color: var(--accent);
  font-weight: 700;
}

/* ペンディング表示 (スマホのみ) */
.kt-pending {
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px;
  background: rgba(228, 179, 76, 0.08);
  border-top: 1px solid rgba(228, 179, 76, 0.2);
  border-bottom: 1px solid rgba(0, 0, 0, 0.3);
  font-size: 12px;
}
.kt-pending.show {
  display: flex;
}
.kt-pending-hint {
  color: var(--text-dim);
  font-size: 11px;
}
.kt-pending-char {
  font-family: var(--font-display);
  font-size: 24px;
  color: var(--accent);
  font-weight: 700;
  background: rgba(228, 179, 76, 0.2);
  padding: 0 10px;
  border-radius: 6px;
  min-width: 36px;
  text-align: center;
  animation: pending-blink 800ms ease-in-out infinite;
}
@keyframes pending-blink {
  0%, 100% { box-shadow: 0 0 0 rgba(228, 179, 76, 0); }
  50% { box-shadow: 0 0 12px rgba(228, 179, 76, 0.6); }
}

.kt-pc .kt-pending { display: none !important; }

/* === スマホ用: ネイティブ IME 入力フィールド === */
.kt-input-wrap {
  background: rgba(0, 0, 0, 0.55);
  padding: 12px 14px env(safe-area-inset-bottom, 12px);
  border-top: 1px solid rgba(228, 179, 76, 0.3);
}
#kanaInput {
  width: 100%;
  height: 56px;
  background: rgba(255, 255, 255, 0.96);
  color: #14181f;
  border: 2px solid var(--accent);
  border-radius: 10px;
  padding: 0 16px;
  font-size: 26px;
  font-family: var(--font-display);
  letter-spacing: 0.12em;
  text-align: center;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  caret-color: var(--accent-dark);
}
#kanaInput:focus {
  box-shadow: 0 0 0 4px rgba(228, 179, 76, 0.25);
}
.kt-input-hint {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-top: 6px;
  line-height: 1.4;
}

/* PC では入力欄ごと非表示。フリックの旧 UI も非表示 */
.kt-pc .kt-input-wrap { display: none; }
.kt-pc .flick-pad { display: none; }
.kt-pc .kt-pending { display: none !important; }

/* 旧フリックキーボード(現在未使用)が念のため出てしまった場合の保険 */
.flick-pad { display: none; }

.flick-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
}

.flick-key {
  position: relative;
  background: var(--kb-key-bg);
  border: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--kb-key-text);
  font-family: var(--font-display);
  font-size: 22px;
  border-radius: 8px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  transition: background 80ms;
  padding: 0;
}
.flick-key:active,
.flick-key.active {
  background: #4a5f87;
}
.flick-key.flick-modifier {
  background: var(--kb-key-bg-mod);
  font-size: 18px;
  color: var(--kb-key-text-dim);
}
.flick-key.flick-modifier.usable {
  background: var(--accent-dark);
  color: #14181f;
}
.flick-key.flick-modifier:active,
.flick-key.flick-modifier.active {
  background: var(--accent);
  color: #14181f;
}

.flick-spacer {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 8px;
  height: 48px;
}

/* キー上の小さなフリック方向ヒント */
.flick-key-hint {
  position: absolute;
  inset: 2px;
  pointer-events: none;
  font-size: 9px;
  color: var(--kb-key-text-dim);
  opacity: 0.7;
}
.flick-key-hint .h-left,
.flick-key-hint .h-right,
.flick-key-hint .h-up,
.flick-key-hint .h-down {
  position: absolute;
}
.flick-key-hint .h-left { left: 3px; top: 50%; transform: translateY(-50%); }
.flick-key-hint .h-right { right: 3px; top: 50%; transform: translateY(-50%); }
.flick-key-hint .h-up { left: 50%; top: 2px; transform: translateX(-50%); }
.flick-key-hint .h-down { left: 50%; bottom: 2px; transform: translateX(-50%); }

/* フリック中のポップアップ */
.flick-popup {
  position: absolute;
  inset: -64px -52px;
  pointer-events: none;
  display: none;
  z-index: 10;
}
.flick-popup.show { display: block; }
.flick-pop {
  position: absolute;
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: rgba(20, 28, 44, 0.95);
  border: 1px solid rgba(228, 179, 76, 0.4);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.flick-pop.center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(228, 179, 76, 0.95);
  color: #14181f;
}
.flick-pop.left  { left: 4px;  top: 50%; transform: translate(0, -50%); }
.flick-pop.right { right: 4px; top: 50%; transform: translate(0, -50%); }
.flick-pop.up    { left: 50%; top: 4px;  transform: translate(-50%, 0); }
.flick-pop.down  { left: 50%; bottom: 4px; transform: translate(-50%, 0); }
.flick-pop.highlight {
  background: rgba(228, 179, 76, 0.95);
  color: #14181f;
  box-shadow: 0 0 12px rgba(228, 179, 76, 0.6);
}

/* PC ではキーボードは非表示 */
.kt-pc .flick-pad { display: none; }
.kt-pc .kt-stage { padding-bottom: 14px; }

/* タイトル / 結果モーダル */
.kt-modal {
  /* モバイルでは absolute (#app に対する) のままにする。
     iOS Safari は position:fixed の要素に overflow:auto を組み合わせた
     場合にスクロールが効かなくなる既知の挙動があり、iPhone SE 等の
     小さい画面でメニュー画面が下までスクロールできなくなる。 */
  position: absolute;
  inset: 0;
  background: rgba(8, 13, 22, 0.92);
  backdrop-filter: blur(8px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  z-index: 20;
  padding: calc(20px + env(safe-area-inset-top, 0px)) 20px calc(20px + env(safe-area-inset-bottom, 0px));
  text-align: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

/* PC は #app に max-width:880px が掛かっているので、モーダルを
   absolute のままにすると外側 (フレームの両脇) でホイールしても
   モーダルがスクロールしない。PC のみ fixed にして viewport 全体を
   覆い、どこにマウスがあってもスクロールできるようにする。 */
.kt-pc .kt-modal {
  position: fixed;
}
.kt-modal.hidden { display: none; }

.kt-modal h1 {
  font-family: var(--font-display);
  font-size: clamp(32px, 7vw, 48px);
  margin: 0 0 8px;
}
.kt-modal h1 .accent { color: var(--accent); }
.kt-modal h2 {
  font-family: var(--font-display);
  font-size: clamp(20px, 4.5vw, 28px);
  margin: 0 0 12px;
}
.kt-modal p {
  margin: 4px 0;
  color: var(--text);
  max-width: 480px;
  line-height: 1.7;
  font-size: 14px;
}
.kt-modal .rules {
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  padding: 14px 16px;
  margin: 16px 0;
  text-align: left;
  max-width: 480px;
  width: 100%;
}
.kt-modal .rules li {
  margin: 6px 0;
  font-size: 13px;
  color: var(--text);
}
.kt-modal code {
  background: rgba(255, 255, 255, 0.08);
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font-display);
  color: var(--accent);
}

/* PC は画面が広く文字が相対的に小さく見えるため、説明文を少し
   大きく・行間を広げて読みやすくする (スマホは元のサイズを維持)。 */
.kt-pc .kt-modal p {
  font-size: 15px;
}
.kt-pc .kt-modal .rules li {
  font-size: 14.5px;
  line-height: 1.7;
}

.kt-button {
  background: var(--accent);
  color: #14181f;
  border: none;
  border-radius: 999px;
  padding: 11px 28px;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  margin: 4px;
  letter-spacing: 0.08em;
  display: inline-block;
  text-decoration: none;
}
.kt-button:hover { background: #f1c463; }
.kt-button.secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}
.kt-button.secondary:hover {
  background: rgba(228, 179, 76, 0.1);
}

.kt-button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 12px 0;
}

.kt-mode-select {
  display: inline-flex;
  align-items: center;
  align-self: center;
  gap: 4px;
  margin: 6px auto;
  padding: 3px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  flex-wrap: wrap;
  justify-content: center;
}
.kt-mode-select-title {
  font-size: 11px;
  color: var(--text-dim);
  padding: 0 8px 0 10px;
  letter-spacing: 0.08em;
}
.kt-mode-option {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  letter-spacing: 0.04em;
  transition: background 120ms, color 120ms;
}
.kt-mode-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}
.kt-mode-option:has(input:checked) {
  background: var(--accent);
  color: #14181f;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
}

.kt-result-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 24px;
  margin: 14px 0;
  max-width: 420px;
  width: 100%;
}
.kt-result-grid .label {
  text-align: right;
  color: var(--text-dim);
  font-size: 13px;
}
.kt-result-grid .value {
  text-align: left;
  font-size: 17px;
  font-weight: 700;
}
.kt-result-grid .value.gain { color: var(--green); }
.kt-result-grid .value.loss { color: var(--red); }

.kt-name-input {
  display: flex;
  gap: 8px;
  margin: 10px auto;
  width: 100%;
  max-width: 320px;
}
.kt-name-input input {
  flex: 1;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 16px;
}

.kt-ranking {
  width: 100%;
  max-width: 460px;
  margin: 12px auto;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 8px;
  overflow: hidden;
  max-height: 220px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  /* モーダルは display:flex; flex-direction:column。flex item の min-height は
     既定で auto だが、overflow を指定すると 0 に解決される。default の
     flex-shrink:1 と組み合わさると、コンテンツがあっても高さ 0 まで
     潰されてランキングが空欄に見える。flex-shrink:0 で natural size を維持。 */
  flex-shrink: 0;
}

.kt-ranking-row {
  display: grid;
  grid-template-columns: 44px 1fr 80px;
  padding: 8px 12px;
  font-size: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.kt-ranking-row:last-child { border-bottom: none; }
.kt-ranking-row.you { background: rgba(228, 179, 76, 0.15); }
.kt-ranking-row .rank { color: var(--accent); font-weight: 700; }
.kt-ranking-row .name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.kt-ranking-row .score {
  text-align: right;
  color: var(--text);
  font-weight: 600;
}

.kt-error { color: var(--red); font-size: 13px; margin: 8px 0; }
.kt-info  { color: var(--green); font-size: 13px; margin: 8px 0; }

.kt-ranking-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 460px;
  margin: 0 auto 4px;
  gap: 8px;
}
.kt-button-tiny {
  background: rgba(228, 179, 76, 0.18);
  color: var(--accent);
  border: 1px solid rgba(228, 179, 76, 0.45);
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.04em;
}
.kt-button-tiny:hover {
  background: rgba(228, 179, 76, 0.3);
}
.kt-ranking-status {
  width: 100%;
  max-width: 460px;
  margin: 0 auto 6px;
  text-align: center;
  font-size: 12px;
  color: var(--text-dim);
  min-height: 16px;
}
.kt-ranking-status.error { color: var(--red); }
.kt-ranking-status.info  { color: var(--accent); }

/* タイマーバー */
.kt-timer-bar {
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  background: var(--accent);
  transition: width 250ms linear;
  z-index: 10;
}

/* フローティングメッセージ */
.kt-flash {
  position: absolute;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 22px;
  pointer-events: none;
  z-index: 6;
  animation: flash-up 900ms ease-out forwards;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.6);
}
.kt-flash.good  { color: var(--green); }
.kt-flash.bad   { color: var(--red); }
.kt-flash.time  { color: var(--blue); font-size: 18px; }
.kt-flash.combo { color: var(--accent); font-size: 20px; }

@keyframes flash-up {
  0%   { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-60px); }
}

.kt-mobile .kt-plate {
  top: 58%;
}

/* PC 向け広め */
@media (min-width: 760px) and (hover: hover) {
  .kt-conveyor { min-height: 360px; }
}

/* PC では sushida.net 風に中央寄せ + 幅制限。
   body の暗いグラデーションが左右に見えて「フレーム」っぽくなる。 */
#app.kt-pc {
  max-width: 880px;
  margin-left: auto;
  margin-right: auto;
  box-shadow: 0 0 60px rgba(0, 0, 0, 0.6);
}

@supports (padding: env(safe-area-inset-bottom)) {
  .flick-pad {
    padding-bottom: calc(8px + env(safe-area-inset-bottom));
  }
}
