/* ==========================================
   てんとくんドロップ
   共通部分（色・ボタン・ダイアログ・効果）は ../../assets/css/game-base.css
   ========================================== */
:root {
  --color-field: #0c1426;
  --color-chain: #fde047;
}

/* ==========================================
   Layout
   ========================================== */
.app {
  width: min(100%, 560px);
  margin: 0 auto;
  padding: 16px;
  display: grid;
  gap: 12px;
  touch-action: manipulation; /* ダブルタップで拡大しない（iPhone は連打で効かないことがあるので main.js でも止める） */
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.app-header__title {
  margin: 0;
  min-width: 0;
  font-size: clamp(15px, 4.2vw, 24px);
  letter-spacing: .02em;
  white-space: nowrap;
}
.app-header__tools { display: flex; gap: 4px; }
.icon-btn:disabled { opacity: .35; cursor: default; }

.game {
  display: grid;
  grid-template-columns: auto minmax(0, 180px);
  justify-content: center;
  grid-template-areas:
    "field side"
    "pad pad"
    "keys keys";
  gap: 12px;
  align-items: start;
}

.app-footer {
  text-align: center;
  font-size: 12px;
  color: var(--color-muted);
}

/* ==========================================
   Field（盤面）
   ========================================== */
.field-wrap {
  grid-area: field;
  position: relative;
  border-radius: var(--radius-md);
  overflow: hidden;
}
.field {
  display: block;
  width: 240px;          /* main.js が画面に合わせて書き換える */
  height: 500px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-field);
  touch-action: none;    /* スワイプで画面がスクロールしないように */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

/* 連鎖数の表示 */
.chain-layer { position: absolute; inset: 0; pointer-events: none; }
.chain-pop {
  position: absolute;
  margin: 0;
  translate: -50% -50%;
  font-size: clamp(18px, 6vw, 26px);
  font-weight: 900;
  white-space: nowrap;
  color: var(--color-chain);
  text-shadow: 0 2px 0 #7c2d12, 0 0 12px rgba(0, 0, 0, .6);
  animation: chain-pop 1s ease-out forwards;
}
.chain-pop small { font-size: .6em; }
@keyframes chain-pop {
  0% { opacity: 0; scale: .5; }
  15% { opacity: 1; scale: 1.15; }
  30% { scale: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; translate: -50% -110%; }
}
.fx-reduced .chain-pop { animation-duration: 1.2s; animation-name: chain-fade; }
@keyframes chain-fade {
  0%, 80% { opacity: 1; }
  100% { opacity: 0; }
}

/* ==========================================
   Screens（タイトル・一時停止・ゲームオーバー）
   ========================================== */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px 12px;
  text-align: center;
  background: rgba(5, 8, 22, .84);
  backdrop-filter: blur(2px);
  border-radius: var(--radius-md);
  overflow-y: auto;
}
.screen[hidden] { display: none; }
.fx-reduced .screen { backdrop-filter: none; }

.screen__face {
  width: clamp(72px, 26%, 120px);
  height: auto;
  border-radius: 24%;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .4);
}
.screen__title { margin: 0; font-size: clamp(18px, 5.5vw, 24px); }
.screen__best { margin: 0; font-size: 13px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.screen__best b { color: var(--color-text); }
.screen__start { min-width: 140px; }
.screen .btn { min-width: 140px; }
.screen__record {
  margin: 0;
  font-weight: 900;
  color: var(--color-chain);
}
.screen__howto {
  margin: 4px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 4px;
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-muted);
}

.modes {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 4px;
  padding: 4px;
  width: min(100%, 220px);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, .5);
}
.modes__btn {
  appearance: none;
  display: grid;
  place-content: center;
  min-height: var(--tap);
  padding: 2px 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--color-muted);
  font: inherit;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
}
.modes__btn small { font-size: 11px; font-weight: 400; }
.modes__btn:hover { color: var(--color-text); }
.modes__btn[aria-pressed="true"] { background: var(--color-surface-raised); color: var(--color-text); box-shadow: inset 0 0 0 1px var(--color-border-strong); }

.result {
  display: flex;
  gap: 20px;
  margin: 0;
}
.result div { display: grid; gap: 2px; }
.result dt { font-size: 12px; color: var(--color-muted); }
.result dd { margin: 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

/* ==========================================
   Side（NEXT・スコア）
   ========================================== */
.side {
  grid-area: side;
  min-width: 0;
  display: grid;
  gap: 8px;
}
/* 上の段：左にプレイ時間、右に一時停止 */
.side__top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side__time { margin: 0; min-width: 0; }
.side__time .panel__label { display: block; }
.panel {
  padding: 6px 10px 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: rgba(2, 6, 23, .35);
}
.panel__label {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: .04em;
  color: var(--color-muted);
}
.next { justify-self: stretch; }
.next__canvas { display: block; margin: 2px auto 0; }
.stat__value {
  display: block;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
  overflow-wrap: anywhere;
}
.stat__value--big { font-size: clamp(16px, 5vw, 22px); }
.stat__value--small { font-size: 16px; }
.stat__sub { display: block; font-size: 11px; color: var(--color-muted); font-variant-numeric: tabular-nums; }
.stat__sub--lines { white-space: pre-line; }   /* 文中の改行で行を分ける */

/* ==========================================
   Pad（操作ボタン）
   ========================================== */
.pad {
  grid-area: pad;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.pad__btn {
  appearance: none;
  display: grid;
  place-items: center;
  min-height: 52px;
  padding: 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: background-color .15s ease, transform .06s ease;
}
.pad__btn svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.pad__btn.is-pressed { background: var(--color-surface-raised); transform: scale(.95); }
.pad__btn:disabled { opacity: .4; }

.keys {
  grid-area: keys;
  margin: 0;
  font-size: 12px;
  text-align: center;
  color: var(--color-muted);
}
/* タッチ操作の端末ではキーボードの説明を出さない */
@media (hover: none) {
  .keys { display: none; }
}

/* ==========================================
   スマホ横向き：左に情報、中央に盤面、右に操作ボタン
   main.js の landscapeQuery と合わせる
   ========================================== */
@media (orientation: landscape) and (max-height: 600px) {
  .app { width: min(100%, 860px); padding: 8px 16px; gap: 6px; }
  .app-footer { display: none; }
  .game {
    grid-template-columns: minmax(96px, 1fr) auto minmax(150px, 1fr);
    grid-template-areas: "side field pad";
    align-items: center;
    justify-content: stretch;
  }
  /* 情報は 2 列にして縦に収める */
  .side { grid-template-columns: 1fr 1fr; gap: 6px; }
  .next, .side__top { grid-column: 1 / -1; }
  .panel { padding: 4px 8px 6px; }
  .stat__value, .stat__value--big { font-size: 16px; }
  .stat__value--small { font-size: 14px; }
  /* 盤面が小さいので、タイトル画面は絵と説明を省く */
  .screen { gap: 8px; padding: 10px 8px; }
  .screen__face, .screen__howto { display: none; }
  .screen__title { font-size: 17px; }
  .screen .btn { min-width: 0; width: 100%; }
  .pad {
    grid-template-columns: 1fr 1fr;
    grid-template-areas:
      "rotl rotr"
      "left right"
      "down down";
  }
  .pad__btn[data-action="rotl"] { grid-area: rotl; }
  .pad__btn[data-action="rotr"] { grid-area: rotr; }
  .pad__btn[data-action="left"] { grid-area: left; }
  .pad__btn[data-action="right"] { grid-area: right; }
  .pad__btn[data-action="down"] { grid-area: down; }
  .keys { display: none; }
}
