/* Ryumon デモ（ブラウザ版）。インラインの style は使わない（Content-Security-Policy の style-src 'self'） */
:root {
  --bg: #0f1115;
  --panel: #181b22;
  --text: #e6e8ee;
  --muted: #9aa1b2;
  --line: #2a2f3a;
  --accent: #3b82f6;
  --font: "Noto Sans JP", "Noto Sans CJK JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo UI", "Meiryo", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.5 var(--font);
  -webkit-text-size-adjust: 100%;
}

.app {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 16px 24px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 0;
}
.top .spacer { flex: 1 1 auto; }
.status { font-weight: 700; }

button {
  font: inherit;
  color: var(--text);
  background: #232834;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 12px;
  cursor: pointer;
}
button:hover { background: #2c3342; }
button:active { background: #353d50; }
button[hidden] { display: none; }

.stage {
  position: relative;
  line-height: 0;
}
#screen {
  display: block;
  width: 100%;
  max-width: 512px;
  aspect-ratio: 512 / 544;
  margin: 0 auto;
  background: #000;
  image-rendering: pixelated;
  touch-action: none;
  outline: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
#screen:focus-visible { outline: 2px solid var(--accent); }

.conn {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  text-align: center;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-weight: 700;
}
.conn[hidden] { display: none; }

/* 画面の十字ボタンと Z/X ボタン（触れる端末のとき） */
.pad {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  max-width: 512px;
  margin: 10px auto 0;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  touch-action: none;
}
.pad[hidden] { display: none; }
.pad button { touch-action: none; -webkit-tap-highlight-color: transparent; }
.dpad {
  display: grid;
  grid-template-columns: repeat(3, 56px);
  grid-template-rows: repeat(3, 56px);
  grid-template-areas:
    ". up ."
    "left . right"
    ". down .";
  gap: 4px;
}
.dpad button { font-size: 20px; padding: 0; }
.dpad .up { grid-area: up; }
.dpad .left { grid-area: left; }
.dpad .right { grid-area: right; }
.dpad .down { grid-area: down; }
.spells { display: flex; flex-direction: column; gap: 10px; }
.spells button { min-width: 120px; min-height: 56px; font-size: 16px; font-weight: 700; }

.info { margin-top: 8px; min-height: 1.5em; }
.meter {
  display: block;
  width: 100%;
  height: 8px;
  border: 0;
  border-radius: 0;
  background: #222;
  appearance: none;
  -webkit-appearance: none;
  margin-top: 2px;
}
.meter[hidden] { display: none; }
.meter.mp { height: 6px; }
.meter::-webkit-progress-bar { background: #222; }
.meter::-webkit-progress-value { background: var(--bar, #22c55e); }
.meter::-moz-progress-bar { background: var(--bar, #22c55e); }
.meter.hp { --bar: #22c55e; }
.meter.hp.mid { --bar: #f59e0b; }
.meter.hp.low { --bar: #ef4444; }
.meter.mp { --bar: #3b82f6; }

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.presets[hidden] { display: none; }

.chat {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}
.chat[hidden] { display: none; }
.chat input { flex: 1 1 auto; min-width: 0; }

input[type="text"], input[type="password"] {
  font: inherit;
  color: var(--text);
  background: #11141a;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 6px 8px;
  width: 100%;
}

.log {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  height: 7.5em;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
  font-size: 13px;
}
.log li { padding: 1px 8px; }
.log li.err { color: #fca5a5; }

.help { margin-top: 12px; color: var(--muted); font-size: 13px; }
.help summary { cursor: pointer; }
.help ul { padding-left: 1.2em; }

dialog {
  color: var(--text);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 16px;
  width: min(92vw, 420px);
}
dialog::backdrop { background: rgba(0, 0, 0, 0.6); }
dialog h2 { margin: 0 0 8px; font-size: 18px; }
dialog label { display: block; margin: 8px 0; }
dialog label input { display: block; margin-top: 2px; }
dialog p { margin: 8px 0; }
dialog pre {
  background: #11141a;
  border-radius: 6px;
  padding: 8px;
  font: 14px/1.6 ui-monospace, "Cascadia Mono", Consolas, monospace;
  user-select: all;
}
.row { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.qr { display: block; margin: 8px auto; background: #fff; image-rendering: pixelated; }

@media (max-width: 420px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .dpad { grid-template-columns: repeat(3, 52px); grid-template-rows: repeat(3, 52px); }
}
