/* =========================================================
   厚焼き卵ゲーム 試作 v1 — style.css
   レイアウト・HUD・ボタン。外部フォント/ライブラリは使わない。
   iPad mini の縦横両対応・セーフエリア対応・100dvh フルスクリーン。
   ========================================================= */

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }
body {
  height: 100vh;
  height: 100dvh;               /* iOS Safari のアドレスバー変動対策 */
  overflow: hidden;
  background: #171009;
  color: #fff6e0;
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Kaku Gothic ProN",
               "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif;
  overscroll-behavior: none;    /* プルトゥリフレッシュ抑止 */
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#app { position: fixed; inset: 0; height: 100vh; height: 100dvh; }

/* ---- ゲームCanvas(画面全体=卵焼き器の底面) ---- */
#pan {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  display: block;
  touch-action: none;           /* ブラウザジェスチャーを無効化 */
}

/* ---- HUD: 状態テキストとメーター ---- */
#hud {
  position: absolute;
  top: calc(env(safe-area-inset-top, 0px) + 10px);
  left: 16px; right: 16px;
  display: flex; justify-content: space-between; align-items: flex-start; gap: 12px;
  pointer-events: none;         /* 下のCanvasにタップを通す */
}
#state-text {
  font-size: clamp(15px, 2.6vh, 22px);
  font-weight: 700; line-height: 1.35;
  text-shadow: 0 1px 4px rgba(0,0,0,.7);
  max-width: 46vw;
}
#meters {
  width: min(200px, 38vw);
  background: rgba(10,6,2,.5);
  border: 1px solid rgba(255,240,200,.15);
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 12px;
  display: grid; gap: 6px;
}
.meter-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.meter-row .track {
  flex: 1; height: 10px;
  background: rgba(255,255,255,.14);
  border-radius: 5px; overflow: hidden;
}
#cook-meter {
  display: block; height: 100%; width: 0%;
  background: #ffcf4d; border-radius: 5px;
  transition: width .15s linear, background .3s;
}
#layer-count { font-size: 16px; font-weight: 800; color: #ffd95e; min-width: 2em; text-align: right; }

/* ---- 傾きインジケーター(小さく表示) ---- */
#tilt-indicator {
  position: absolute;
  left: 16px;
  top: calc(env(safe-area-inset-top, 0px) + 64px);
  width: 54px; height: 54px;
  border-radius: 50%;
  background: rgba(10,6,2,.45);
  border: 2px solid rgba(255,240,200,.25);
  pointer-events: none;
}
#tilt-dot {
  position: absolute; left: 50%; top: 50%;
  width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border-radius: 50%;
  background: #ffd23f;
  box-shadow: 0 0 8px rgba(255,210,63,.9);
}

/* ---- トースト(短いメッセージ) ---- */
#toast {
  position: absolute;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 104px);
  transform: translateX(-50%);
  background: rgba(24,13,3,.88);
  color: #ffe9b0;
  padding: 10px 20px;
  border-radius: 999px;
  font-size: 15px; font-weight: 700;
  white-space: nowrap; max-width: 94vw;
  overflow: hidden; text-overflow: ellipsis;
  pointer-events: none;
  transition: opacity .25s, visibility .25s;
}
#toast.hidden { opacity: 0; visibility: hidden; }

/* ---- 操作ボタン(大きくタッチしやすく) ---- */
#controls {
  position: absolute; left: 0; right: 0; bottom: 0;
  display: flex; justify-content: center; align-items: stretch; gap: 10px;
  padding: 10px 14px calc(env(safe-area-inset-bottom, 0px) + 14px);
}
#controls button {
  appearance: none; -webkit-appearance: none;
  border: 0; border-radius: 16px;
  min-height: 58px;
  flex: 1 1 150px; max-width: 250px;
  font-size: 17px; font-weight: 800;
  font-family: inherit;
  color: #46300f;
  background: linear-gradient(#ffe089, #f2b53a);
  box-shadow: 0 4px 0 #9c6d1c, 0 6px 14px rgba(0,0,0,.45);
  touch-action: manipulation;
}
#controls button:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #9c6d1c, 0 3px 8px rgba(0,0,0,.4);
}
#controls button:disabled { filter: saturate(.45) brightness(.8); transform: none; }
#btn-sensor {
  background: linear-gradient(#d7e9ff, #8fb9e6);
  box-shadow: 0 4px 0 #4c6d92, 0 6px 14px rgba(0,0,0,.4);
  color: #1d3350;
}
#btn-reset {
  background: linear-gradient(#efe9df, #b7ad9e);
  box-shadow: 0 4px 0 #6f675a, 0 6px 14px rgba(0,0,0,.4);
  color: #3c342a;
  flex: 0 1 120px;
}

/* ---- 横持ちなど背の低い画面でのコンパクト化 ---- */
@media (max-height: 480px) {
  #controls button { min-height: 48px; font-size: 15px; }
  #state-text { font-size: 15px; }
  #tilt-indicator { width: 44px; height: 44px; top: calc(env(safe-area-inset-top, 0px) + 46px); }
  #toast { bottom: calc(env(safe-area-inset-bottom, 0px) + 72px); font-size: 13px; }
}
