:root {
  color-scheme: light;
  --ink: #4a3b2e;
  --paper: #fff8ec;
  --accent: #f0904a;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 16px;
  background: linear-gradient(160deg, #ffeccd, #ffdfe0);
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
}

/* つなぎの帯。遊びの邪魔にならないよう、画面のいちばん上に細く出す。 */
#connection {
  margin: -16px -16px 12px;
  padding: 8px 16px;
  background: #b8543a;
  color: #fff8ec;
  font-size: 16px;
  font-weight: bold;
  text-align: center;
}

#connection[hidden] {
  display: none;
}

#hud {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px 24px;
  max-width: 1120px;
  margin: 0 auto 12px;
}

#hud h1 {
  margin: 0;
  font-size: 22px;
  letter-spacing: 0.04em;
}

.gauges {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.gauges .label {
  font-size: 13px;
  opacity: 0.7;
  margin-left: 12px;
}

#clock.hurry {
  color: #d2452f;
  font-weight: 700;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 20px;
  justify-content: center;
  align-items: flex-start;
  max-width: 1120px;
  margin: 0 auto;
}

#board {
  position: relative;
}

canvas {
  display: block;
  max-width: 100%;
  height: auto;
  border-radius: 14px;
  box-shadow: 0 10px 24px rgba(90, 60, 30, 0.22);
  background: var(--paper);
}

/* 知らせは手の少し上に短く出して、自動で消える。 */
#notice {
  position: absolute;
  left: 50%;
  bottom: 12%;
  transform: translate(-50%, 8px);
  margin: 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: rgba(74, 59, 46, 0.88);
  color: #fff8ec;
  font-size: 16px;
  white-space: nowrap;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
  pointer-events: none;
}

#notice.shown {
  opacity: 1;
  transform: translate(-50%, 0);
}

/*
 * 名前の入力。盤の上に小さく浮かせる（初めて開いた人にはここしか押せない）。
 * 名乗り終われば消えて、以後は「なまえを変える」からだけ呼び出される。
 */
#name-form {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255, 248, 236, 0.97);
  box-shadow: 0 8px 20px rgba(90, 60, 30, 0.28);
  font-size: 15px;
  white-space: nowrap;
}

#name-form[hidden] {
  display: none;
}

#name-input {
  width: 11em;
  padding: 5px 10px;
  border: 1px solid rgba(74, 59, 46, 0.35);
  border-radius: 999px;
  background: #fff;
  color: inherit;
  font: inherit;
}

#name-submit,
#name-change {
  padding: 5px 12px;
  border: 1px solid rgba(74, 59, 46, 0.35);
  border-radius: 999px;
  background: var(--accent);
  color: var(--paper);
  font: inherit;
  cursor: pointer;
}

#name-change {
  padding: 2px 10px;
  background: var(--paper);
  color: inherit;
  font-size: 12px;
}

/* いまの自分の名前。名札と同じものを、あそびかた欄でも読めるようにする。 */
#whoami {
  margin: 10px 0 0;
  font-size: 13px;
}

#result {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 14px;
  background: rgba(255, 248, 236, 0.94);
  text-align: center;
}

#result.shown {
  display: flex;
}

#result p {
  margin: 0;
  font-size: 20px;
}

#result p:first-child {
  font-size: 26px;
  font-weight: 700;
}

/* 次の月までの残り。読む邪魔にならないよう小さく、薄く出す。 */
#result p.countdown {
  margin-top: 4px;
  color: #a08c76;
  font-size: 14px;
}

#help {
  width: min(320px, 100%);
  padding: 14px 18px;
  border-radius: 14px;
  background: rgba(255, 248, 236, 0.86);
  box-shadow: 0 6px 16px rgba(90, 60, 30, 0.14);
}

#help h2 {
  margin: 0 0 8px;
  font-size: 16px;
}

#help ul {
  margin: 0;
  padding-left: 1.1em;
  line-height: 1.7;
  font-size: 14px;
}

/* あそびかたの絵は、盤面の印と同じ素材をそのまま並べる。 */
#help img {
  width: 22px;
  height: 22px;
  vertical-align: -5px;
}

#settings {
  display: block;
  margin-top: 10px;
  font-size: 13px;
  opacity: 0.85;
}

/* 調整パネル（デバッグ）。あそびかた欄と同じ見た目で、簡素に並べるだけ。 */
#debug[hidden] {
  display: none;
}

#debug {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px dashed rgba(74, 59, 46, 0.3);
  font-size: 13px;
}

#debug h3 {
  margin: 0 0 6px;
  font-size: 14px;
}

.debug-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.debug-row span {
  flex: 1;
}

.debug-row input {
  width: 68px;
  font: inherit;
  font-family: inherit;
}

#debug-reset {
  margin-top: 6px;
  padding: 4px 10px;
  border: 1px solid rgba(74, 59, 46, 0.35);
  border-radius: 8px;
  background: var(--paper);
  color: inherit;
  font: inherit;
  cursor: pointer;
}

/* 状態の1行サマリ。毎秒書き換わるので、幅の動く数字は等幅で並べる。 */
#debug-status {
  margin: 8px 0 4px;
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  opacity: 0.85;
}

/* ゲームログ。高さを決めて、はみ出したぶんは中でスクロールさせる。 */
#debug-log {
  height: 200px;
  overflow-y: auto;
  padding: 6px 8px;
  border: 1px solid rgba(74, 59, 46, 0.25);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.55);
  font-family: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
  font-size: 11px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
