:root {
  color-scheme: light;
  --forest-ink: #16392f;
  --leaf: #22664c;
  --bright-leaf: #bee281;
  --mist: #e8f2db;
  --gold: #efbe65;
  --paper: #f7f6dc;
  --ink: var(--forest-ink);
  --cream: var(--paper);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 24px 16px 34px;
  background: var(--mist);
  color: var(--forest-ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  touch-action: manipulation;
}

h1 {
  margin: 1px 0 2px;
  font-size: clamp(1.65rem, 4vw, 2.3rem);
  line-height: 1;
  letter-spacing: 0.22em;
  text-shadow: none;
}

canvas {
  width: 100%;
  border-radius: 8px;
  box-shadow: 0 8px 0 rgba(22, 57, 47, 0.18), 0 0 0 3px var(--forest-ink);
  background: #000;
  display: block;
  height: auto;
}

#game-wrap {
  position: relative;
  width: 100%;
}

#name-input {
  position: absolute;
  display: none;
  box-sizing: border-box;
  border: 2px solid var(--forest-ink);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 18px;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", sans-serif;
  background: var(--paper);
  color: var(--forest-ink);
}

#name-input.visible {
  display: block;
}

.app-shell {
  width: min(720px, 100%);
}

.site-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  margin: 0 4px 15px;
}

.tagline {
  margin: 7px 0 0;
  color: var(--leaf);
  font-size: 0.84rem;
}

.status-stack {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.status-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 27px;
  padding: 5px 10px;
  border: 1px solid rgba(22, 57, 47, 0.22);
  border-radius: 999px;
  background: rgba(247, 246, 220, 0.74);
  color: var(--forest-ink);
  font-size: 0.7rem;
  white-space: nowrap;
}

.status-chip i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--leaf);
  box-shadow: none;
}

.play-meta {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  margin: 12px 4px 0;
}

.save-note {
  margin: 3px 0;
  color: #416b55;
  font-size: 0.77rem;
}

.save-note span {
  color: var(--gold);
}

.guide {
  width: min(460px, 72%);
  padding: 8px 11px;
  border: 1px solid rgba(22, 57, 47, 0.22);
  border-radius: 12px;
  background: rgba(247, 246, 220, 0.72);
  color: var(--forest-ink);
  font-size: 0.75rem;
}

.guide summary {
  cursor: pointer;
  color: var(--forest-ink);
  font-weight: 800;
  text-align: right;
}

.guide-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px 12px;
  padding-top: 10px;
}

kbd {
  display: inline-block;
  min-width: 28px;
  padding: 2px 5px;
  border: 1px solid rgba(22, 57, 47, 0.35);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: var(--paper);
  color: var(--forest-ink);
  font: inherit;
  font-weight: 800;
}

#dev-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 10px 4px 0;
  padding: 8px;
  border: 1px dashed rgba(246, 199, 90, 0.38);
  border-radius: 10px;
  background: rgba(12, 14, 27, 0.46);
}

#dev-tools[hidden] {
  display: none;
}

#dev-tools button {
  min-height: 30px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.09);
  color: #fff9e8;
  font: inherit;
  font-size: 11px;
  cursor: pointer;
}

#dev-state {
  flex-basis: 100%;
  color: #bac0df;
  font: 10px ui-monospace, SFMono-Regular, Menlo, monospace;
  overflow-wrap: anywhere;
}

#touch-controls {
  display: none;
  position: relative;
  width: 100%;
  max-width: 720px;
  box-sizing: border-box;
  padding: 14px 4px 0;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

#pad-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

@media (pointer: coarse) {
  #touch-controls {
    display: flex;
  }
  .kbd-only {
    display: none;
  }
}

#touch-controls button {
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  border: none;
  font-family: inherit;
  font-weight: bold;
  color: var(--ink);
  background: var(--cream);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.35);
}

#touch-controls button:focus-visible,
.guide summary:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 3px;
}

#touch-controls button:active {
  background: #ffd75e;
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.35);
}

#dpad {
  position: relative;
  width: 148px;
  height: 148px;
  flex-shrink: 0;
}

.dpad-btn {
  position: absolute;
  width: 52px;
  height: 52px;
  font-size: 20px;
  border-radius: 10px;
}

.dpad-up { top: 0; left: 48px; }
.dpad-down { top: 96px; left: 48px; }
.dpad-left { top: 48px; left: 0; }
.dpad-right { top: 48px; left: 96px; }

#ok-cancel {
  display: flex;
  align-items: center;
  gap: 11px;
}

.round-btn {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  font-size: 14px;
  display: grid;
  place-content: center;
  line-height: 1.05;
}

.round-btn small {
  margin-top: 3px;
  font-size: 10px;
  opacity: 0.64;
}

#touch-controls .ok-btn { background: var(--gold); }
#touch-controls .cancel-btn { background: #f1c9bd; }

/* 縦1列だと7個ぶんの高さがタッチ操作欄を超え、ゲーム画面に重なっていた。
   横1列にして操作欄の中に収める。 */
#misc-buttons {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
}

.misc-btn {
  min-width: 58px;
  min-height: 44px;
  padding: 0 9px;
  border-radius: 8px;
  font-size: 12px;
  opacity: 0.92;
}

@media (max-width: 560px) {
  body {
    padding: 12px 10px 22px;
  }

  .site-header {
    margin-bottom: 10px;
  }

  .overline,
  .status-stack,
  .save-note {
    display: none;
  }

  .tagline {
    font-size: 0.72rem;
  }

  canvas {
    border-radius: 15px;
  }

  .play-meta {
    display: none;
  }

  #touch-controls {
    display: flex;
  }

  .kbd-only {
    display: none;
  }

  #dev-tools {
    margin-inline: 0;
  }

  #dpad {
    transform: scale(0.9);
    transform-origin: left center;
    margin-right: -14px;
  }

  .round-btn {
    width: 62px;
    height: 62px;
  }

  #misc-buttons {
    gap: 6px;
  }

  .misc-btn {
    min-width: 52px;
    flex: 1 1 52px;
  }
}

/* 2026-10-02: 再制作版の操作と保存状態 */
.pause-button { min-height:44px; padding:9px 14px; border:2px solid #22664c; border-radius:12px; background:#f7f6dc; color:#16392f; font:inherit; font-weight:700; cursor:pointer; }
.pause-button[aria-pressed="true"] { background:#22664c; color:#f7f6dc; }
.pause-button:focus-visible, #touch-controls button:focus-visible { outline:3px solid #efbe65; outline-offset:3px; }
#game-wrap { isolation:isolate; }
#game { touch-action:manipulation; }
#touch-controls [data-action] { touch-action:none; user-select:none; -webkit-user-select:none; }
.save-note { max-width:40em; line-height:1.7; }
@media(max-width:420px) { .status-stack { gap:7px; } .pause-button { padding:8px 10px; font-size:12px; } .save-note { font-size:11px; } }

/* 探索画面と揃えた、旅道具のような操作パネル。 */
canvas { border-radius: 8px; box-shadow: 0 0 0 3px #213f35, 0 10px 24px #16392f1f; }
#touch-controls { padding-top: 18px; }
#touch-controls button { border: 1px solid #b5b99a; box-shadow: 0 3px 0 #829378; color: #274337; }
#touch-controls .ok-btn { background: #e9c37b; border-color: #bd9654; }
#touch-controls .cancel-btn { background: #dce5c9; border-color: #acb79d; }
#touch-controls button:active { background: #f0d697; box-shadow: 0 1px 0 #829378; }
@media (prefers-reduced-motion: reduce) { #touch-controls button:active { transform: none; } }
