:root {
  /* Light theme palette */
  --bg: #f6f8fc;
  --text: #0f172a;     /* slate-900 */
  --muted: #475569;    /* slate-600 */
  --accent: #2563eb;   /* blue-600 */
  --ok: #16a34a;       /* green-600 */
  --warn: #d97706;     /* amber-600 */
  --ring: rgba(37, 99, 235, .25); /* blue focus ring */
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Kaku Gothic ProN", "Noto Sans JP", "Yu Gothic", "Meiryo", sans-serif;
  color: var(--text);
  background:
    radial-gradient(1200px 600px at 20% -10%, #e8eefc 0%, transparent 60%),
    radial-gradient(1000px 600px at 120% 10%, #e1f4ff 0%, transparent 50%),
    var(--bg);
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}
main.container {
  width: min(920px, 96vw);
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  box-shadow:
    0 2px 6px rgba(0,0,0,.04),
    0 10px 24px rgba(2, 6, 23, .06);
  padding: 22px clamp(16px, 4vw, 30px) 24px;
}
h1 {
  margin: 0 0 8px;
  font-size: clamp(22px, 3.6vw, 30px);
  letter-spacing: .01em;
  display:flex; align-items: baseline; gap:.5rem;
}
h1 .sub { font-size:.85rem; color: var(--muted); font-weight:600; }
p.desc { margin: 4px 0 14px; color: var(--muted); font-size: .98rem; }

/* ── Controls ────────────────────────────────────────────────────────── */
.controls {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  gap: 12px;
  align-items: end;
  margin: 14px 0 8px;
}
.ctrl-group label { font-size: .9rem; color: var(--muted); display:block; margin-bottom:6px; }
label { font-size: .9rem; color: var(--muted); display:block; }

/* Inputs */
#guess {
  width: 100%;
  font-variant-numeric: tabular-nums;
  letter-spacing: .06em;
  padding: 14px 14px;
  font-size: clamp(20px, 6vw, 28px);
  background: #ffffff;
  color: var(--text);
  border: 1px solid #d1d5db;
  border-radius: 12px;
  outline: none;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#guess:hover { background: #fbfdff; }
#guess:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 6px var(--ring);
}
#guess::placeholder{
  font-size: clamp(12px, 2.8vw, 16px); /* 常に小さめ */
  letter-spacing: .02em;
}

/* Buttons & selects */
select, button {
  appearance: none;
  border: 1px solid #d1d5db;
  background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
  color: var(--text);
  padding: 12px 16px;
  border-radius: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: transform .05s ease, filter .15s, border-color .15s, background .15s;
  min-width: 120px;
  min-height: 44px; /* タッチ操作に配慮 */
}
button:hover, select:hover { filter: brightness(1.03); border-color: #cbd5e1; }
button:active { transform: translateY(1px); }
button[disabled] { opacity: .6; cursor: not-allowed; }
#submit {
  background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
  color: #ffffff;
  border-color: #2563eb;
}
#submit:hover { filter: brightness(1.02); }
.ghost {
  background: transparent;
  border-color: #d1d5db;
  min-width: auto;
  padding: 10px 12px;
  font-weight: 600;
  color: #0f172a;
}

/* Status */
#status { margin: 8px 0 10px; font-size: clamp(18px, 4.5vw, 22px); font-weight: 800; letter-spacing: .03em; }
#status.win { color: var(--ok); }
#status.warn { color: var(--warn); }

/* Peek chip */
.answer-chip {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-variant-numeric: tabular-nums;
  color: #334155;
}
img.idoubutton:hover{
      /* 透明度を上げることで、画像の色を薄く見せる。*/
      opacity:0.5;
        /* リンクをホバーしたときのカーソルにする。*/
        cursor: pointer;
        }

        /* 画像をクリックした瞬間 */
        img.idoubutton:active{

        /* 要素を若干下に下げることで、押した感じを出す。*/

        /* 今いる位置から相対的に3px下に配置する。*/
        position: relative;
        top: 3px;
        }

        .buttonc {
            display: flex;
            align-items: center;
            justify-content: center; 
            flex-wrap: wrap;
          }
        .buttonc div{
              align-items: center;
              padding: 20px;
              width: 80px;          
              margin-left: 15px; /* ボタンの左マージンを設定 */
              margin-right: 15px; /* ボタンの左マージンを設定 */
          }  
/* Table */
table { width: 100%; border-collapse: collapse; margin-top: 8px; }
thead th {
  text-align: left; font-weight: 700; color: #64748b;
  font-size: .85rem; padding: 10px 10px; border-bottom: 1px solid #e5e7eb; background: #f8fafc;
}
tbody td {
  padding: 12px 10px;
  border-bottom: 1px dashed #e5e7eb;
  font-variant-numeric: tabular-nums;
}
tbody tr:hover { background: #f9fbff; }
tbody tr.win { background: #ecfdf5; }

.row { display:flex; align-items:center; gap:12px; flex-wrap:wrap; }
.meta { gap:12px; color: var(--muted); font-size:.92rem; margin:2px 0 0; }
.meta .dot { width:6px; height:6px; border-radius:50%; background:#cbd5e1; }
.peeker { font-size:.9rem; color:var(--muted); user-select: none; }
.peeker input { width:16px; height:16px; }
footer { margin-top: 12px; color: var(--muted); font-size: .85rem; }

/* デスクトップでも # 列をやや狭く */
thead th:first-child,
tbody td:first-child {
  width: 5ch;                 /* 3桁まで想定（例: 999） */
  text-align: center;
  padding-inline: 6px;        /* 左右の余白を少し詰める */
}

/* ── Responsive: Tablet (iPad 等) ───────────────────────────────────── */
@media (max-width: 1024px) {
  main.container { width: min(980px, 96vw); padding: 20px clamp(14px, 4vw, 26px); }
  .controls { grid-template-columns: 1fr auto; }
  #guess { font-size: clamp(18px, 5.5vw, 26px); }
  thead th, tbody td { padding: 10px 8px; }
}

/* ── Responsive: Phone (スマホ) ─────────────────────────────────────── */
@media (max-width: 640px) {
  body { padding: 14px; }
  main.container { padding: 16px 14px 18px; border-radius: 14px; }
  h1 { font-size: 22px; }
  h1 .sub { font-size: .8rem; }
  p.desc { font-size: .95rem; }

  /* コントロール群は縦積み＆全幅 */
  .controls {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  #guess { width: 100%; font-size: 22px; padding: 12px 12px; }
  #submit, select, .ghost { width: 100%; min-width: 0; }

  /* ステータス行の密度を上げる */
  #status { font-size: 18px; margin: 6px 0 6px; }
  .meta { gap: 8px; font-size: .9rem; }
  .meta .dot { width:5px; height:5px; }

  /* テーブルは横スクロール可能にして崩れ防止 */
  table { display: block; width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  thead, tbody, tr { display: table; width: 100%; table-layout: fixed; }
  thead th, tbody td { white-space: nowrap; }
  thead th:first-child,
  tbody td:first-child {
    width: 4ch;               /* 2〜3桁想定でさらに狭く */
    padding-inline: 4px;
  }

  /* （任意）他列にも目安幅を配分してヒント列に余白を回す */
  thead th:nth-child(2), tbody td:nth-child(2) { width: 26%; } /* 予想 */
  thead th:nth-child(3), tbody td:nth-child(3) { width: 22%; } /* 結果 */
  thead th:nth-child(4), tbody td:nth-child(4) { width: auto; }/* ヒント優先 */ 
}

/* ── Responsive: Very small phones ─────────────────────────────────── */
@media (max-width: 380px) {
  #guess { font-size: 20px; }
  thead th, tbody td { padding: 8px 6px; }
  .answer-chip { padding: 2px 8px; }
}