:root {
  --bg: #120a18; --panel: #1e1028; --panel2: #2a1838; --line: #4a2a5a;
  --text: #f4ecff; --muted: #b8a8cc; --red: #e02838; --gold: #ffd040; --purple: #b070ff;
}
* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Meiryo", sans-serif;
  touch-action: none; -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent; overscroll-behavior: none;
}
button {
  font: inherit; color: var(--text); background: var(--panel2); border: 2px solid var(--line); border-radius: 8px;
  padding: 6px 10px; min-height: 40px; cursor: pointer; touch-action: manipulation;
}
button:hover { border-color: #7a4a8a; }
button:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
button:disabled { opacity: .38; cursor: default; }
button.on { border-color: var(--gold); background: #4a2a10; }

#app { position: fixed; inset: 0; display: grid; grid-template-rows: auto 1fr auto; grid-template-columns: 1fr; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
#hud { display: flex; align-items: center; gap: 10px; padding: 4px 10px; background: var(--panel); border-bottom: 2px solid var(--line); font-size: 15px; min-height: 44px; flex-wrap: wrap; }
#hud .day { font-weight: bold; color: var(--gold); min-width: 3em; }
#hud .meter { display: inline-flex; align-items: center; gap: 6px; }
#hud .lbl { color: var(--purple); font-size: 13px; }
#hud .bar { display: inline-block; width: 90px; height: 10px; background: #0a0610; border: 1px solid var(--line); border-radius: 5px; overflow: hidden; }
#hud .bar i { display: block; height: 100%; width: 0; background: linear-gradient(90deg, #7a3aa8, #c070ff); }
#hud .info { flex: 1; color: var(--muted); font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
#hud .hudBtns { display: inline-flex; gap: 6px; margin-left: auto; }
#hud .hudBtns button { min-width: 44px; min-height: 36px; padding: 2px 8px; }

#stage { position: relative; overflow: hidden; display: flex; align-items: center; justify-content: center; min-height: 0; }
#cv { display: block; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: crosshair; }
#talk { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: min(96%, 620px); display: flex; gap: 8px; align-items: center;
  background: rgba(20, 10, 28, .9); border: 2px solid var(--line); border-radius: 10px; padding: 6px 10px; pointer-events: none; }
#talk img { width: 44px; height: 44px; border-radius: 8px; object-fit: cover; image-rendering: auto; flex: none; background: #2a1838; }
#talk .tb { display: flex; flex-direction: column; font-size: 14px; line-height: 1.4; }
#talk b { color: var(--gold); font-size: 12px; }
#talk.left { left: 8px; top: 8px; transform: none; flex-direction: column; align-items: flex-start; }
#talk.left img { width: 72px; height: 72px; }
#talk.left .tb { font-size: 16px; }
#talk.side { position: fixed; left: auto; right: 6px; top: auto; bottom: 6px; transform: none; width: 218px; z-index: 5; }
#banner { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); background: rgba(40, 10, 20, .92); border: 2px solid var(--red);
  border-radius: 10px; padding: 6px 14px; font-size: 15px; pointer-events: none; white-space: nowrap; }

#ctrl { display: flex; gap: 6px; padding: 6px 8px; justify-content: center; flex-wrap: wrap; background: var(--panel); border-top: 2px solid var(--line); }
#ctrl .sk { display: flex; flex-direction: column; align-items: center; line-height: 1.15; min-width: 92px; }
#ctrl .sk small { font-size: 11px; color: var(--muted); }
#ctrl .sk .nm { font-weight: bold; }
#ctrl .sub { font-size: 14px; }

/* スマホ横（低い画面）: 右に操作の列 */
@media (orientation: landscape) and (max-height: 540px) {
  #app { grid-template-columns: 1fr 230px; grid-template-rows: auto 1fr; }
  #hud { grid-column: 2; grid-row: 1; border-bottom: 0; border-left: 2px solid var(--line); flex-wrap: wrap; gap: 4px 8px; font-size: 13px; padding: 4px 6px; }
  #hud .info { flex-basis: 100%; white-space: normal; font-size: 12px; }
  #hud .bar { width: 60px; }
  #stage { grid-column: 1; grid-row: 1 / 3; }
  #ctrl { grid-column: 2; grid-row: 2; border-top: 0; border-left: 2px solid var(--line); align-content: flex-start; padding: 4px 6px; gap: 4px; }
  #ctrl .sk { min-width: 0; width: calc(50% - 2px); min-height: 44px; padding: 2px; }
  #ctrl .sk:nth-child(3) { width: 100%; }
  #ctrl .sub { width: calc(50% - 2px); font-size: 12px; padding: 2px; min-height: 40px; }
  #talk { width: 96%; }
  #talk .tb { font-size: 12px; }
  #talk img { width: 34px; height: 34px; }
}
/* スマホ縦 */
@media (orientation: portrait) {
  #hud { font-size: 14px; gap: 6px; padding: 4px 6px; }
  #hud .info { flex-basis: 100%; order: 5; font-size: 13px; }
  #ctrl .sk { min-width: 0; flex: 1 1 30%; min-height: 48px; }
  #ctrl .sub { flex: 1 1 22%; min-height: 44px; padding: 4px 2px; font-size: 13px; }
  #talk .tb { font-size: 13px; }
}

/* 重ねる画面 */
#ov { position: absolute; inset: 0; background: rgba(10, 4, 16, .82); display: flex; align-items: center; justify-content: center; z-index: 10; overflow: auto; padding: 12px; }
#ov[hidden], #talk[hidden], #banner[hidden] { display: none; }
.panel { background: var(--panel); border: 2px solid var(--line); border-radius: 14px; padding: 18px 20px; width: min(94vw, 640px); max-height: 100%; overflow: auto; text-align: center; }
.panel h1 { margin: 4px 0 2px; font-size: clamp(22px, 5vw, 34px); color: var(--gold); line-height: 1.25; }
.panel h1 small { display: block; font-size: .5em; color: #ff8a9a; margin-top: 4px; }
.panel h2 { margin: 0 0 10px; font-size: 22px; color: var(--gold); }
.panel p { line-height: 1.6; margin: 6px 0; }
.panel .btns { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 14px; }
.panel .btns button { min-width: 140px; min-height: 48px; font-size: 16px; }
.panel .note { font-size: 12px; color: var(--muted); }
.title-art { display: flex; justify-content: center; align-items: flex-end; gap: 14px; margin: 8px 0; }
.title-art canvas { image-rendering: pixelated; }
.grade { font-size: 64px; font-weight: bold; color: var(--gold); line-height: 1; margin: 6px 0; text-shadow: 0 0 12px #ff8a30; }
.lines { text-align: left; margin: 10px auto; max-width: 520px; }
.line { display: flex; gap: 10px; align-items: flex-start; margin: 8px 0; }
.line img, .line canvas { width: 48px; height: 48px; border-radius: 8px; flex: none; object-fit: cover; background: #2a1838; image-rendering: auto; }
.line canvas { image-rendering: pixelated; }
.line .tx { line-height: 1.5; }
.line .tx b { display: block; color: var(--gold); font-size: 12px; }

.brief { width: min(94vw, 620px); cursor: pointer; }
.brief .face { width: 96px; height: 96px; border-radius: 12px; object-fit: cover; background: #2a1838; image-rendering: auto; }
.brief canvas.face { image-rendering: pixelated; }
.brief .who { color: var(--gold); font-weight: bold; margin-top: 6px; }
.brief .say { font-size: 18px; line-height: 1.6; min-height: 3.2em; margin: 8px 0; }
.brief .hint { font-size: 12px; color: var(--muted); }

.dex { width: min(96vw, 860px); }
.dexgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; text-align: left; }
.dexcard { background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 8px; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.dexcard canvas { image-rendering: pixelated; width: 48px; height: 48px; }
.dexcard b { font-size: 14px; text-align: center; }
.dexcard p { font-size: 12px; margin: 0; line-height: 1.45; color: var(--muted); }
.dexcard.new { border-color: var(--gold); }

/* 道具・図鑑のつけたし */
.panel h3 { margin: 14px 0 6px; font-size: 16px; color: #ff8a9a; text-align: left; }
.panel h2 small, .panel h3 small { font-size: 13px; color: var(--muted); font-weight: normal; }
.items { width: min(96vw, 760px); }
.itemgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 8px; text-align: left; }
.itemcard { display: flex; gap: 8px; align-items: center; background: var(--panel2); border: 2px solid var(--line); border-radius: 10px; padding: 6px 8px; }
.itemcard canvas { width: 40px; height: 40px; image-rendering: pixelated; flex: none; }
.itemcard .it { flex: 1; min-width: 0; }
.itemcard .it b { font-size: 14px; }
.itemcard .it p { margin: 2px 0 0; font-size: 12px; line-height: 1.4; color: var(--muted); }
.itemcard button { flex: none; min-width: 84px; font-size: 13px; }
.dexcard.hid { border-color: #6a3a7a; }
.dexcard .ura { color: #e8d8ff; border-top: 1px dashed var(--line); padding-top: 4px; margin-top: 2px; }
.dexcard .ura b { display: block; font-size: 11px; color: var(--gold); }
.rewards { text-align: left; margin: 4px 0; padding-left: 1.2em; font-size: 13px; line-height: 1.6; color: var(--muted); }
.rewards li.got { color: var(--text); }
.marks { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; margin: 8px 0 0; }
.marks span { font-size: 12px; border: 1px solid var(--gold); color: var(--gold); border-radius: 999px; padding: 2px 10px; }
.talkpair { border-top: 1px dashed var(--line); margin-top: 8px; padding-top: 4px; }
@media (max-width: 420px) { .itemgrid { grid-template-columns: 1fr; } .itemcard button { min-width: 72px; } }

/* 2026-10-11 作り込み3回目: 案内・止めて掘る・拡大鏡・今週の決まり・設定 */
#hud .rule { min-height: 34px; padding: 2px 8px; font-size: 12px; border-color: #3a7a9a; color: #a0e0ff; background: #102838; border-radius: 999px; }
#tut { position: absolute; left: 50%; top: 6px; transform: translateX(-50%); width: min(96%, 620px); display: flex; gap: 8px; align-items: center; z-index: 4;
  background: rgba(16, 24, 40, .95); border: 2px solid #6ab0e0; border-radius: 10px; padding: 8px 10px; }
#tut img { width: 48px; height: 48px; border-radius: 8px; object-fit: cover; flex: none; background: #2a1838; }
#tut .tb { display: flex; flex-direction: column; font-size: 15px; line-height: 1.45; flex: 1; min-width: 0; }
#tut .tb b { color: #a0e0ff; font-size: 12px; }
#tut .tb b small { color: var(--muted); font-weight: normal; margin-left: 6px; }
#tut .tb em { font-style: normal; color: var(--gold); font-size: 13px; margin-top: 2px; }
#tut .tskip { flex: none; min-height: 36px; font-size: 13px; padding: 2px 10px; }
#tut.left { left: 8px; top: 8px; transform: none; flex-direction: column; align-items: flex-start; }
#tut.left img { width: 64px; height: 64px; }
#tut.left .tb { font-size: 16px; }
#tut.left .tskip { align-self: flex-end; }
#tut.side { position: fixed; left: auto; right: 6px; top: auto; bottom: 6px; transform: none; width: 218px; padding: 4px 6px; gap: 0; }
#tut.side img { display: none; }
#tut.side .tb { font-size: 11.5px; line-height: 1.35; }
#tut.side .tb b { min-height: 24px; }
#tut.side .tb em { font-size: 11px; }
#tut.side .tskip { position: absolute; right: 4px; top: 3px; min-height: 26px; font-size: 11px; padding: 0 8px; }
#tut[hidden], #frozen[hidden], #loupe[hidden], #hud .rule[hidden] { display: none; }
#frozen { position: absolute; left: 50%; bottom: 8px; transform: translateX(-50%); display: flex; gap: 8px; align-items: center; z-index: 4;
  background: rgba(16, 32, 48, .94); border: 2px solid #6ab0e0; border-radius: 10px; padding: 4px 8px; font-size: 14px; white-space: nowrap; }
#frozen button { min-height: 40px; font-size: 14px; padding: 2px 10px; }
#loupe { position: absolute; z-index: 6; pointer-events: none; border-radius: 50%; border: 3px solid #f4ecff; box-shadow: 0 2px 10px rgba(0,0,0,.6); image-rendering: pixelated; }
@keyframes hlPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 208, 64, .0); border-color: var(--gold); } 50% { box-shadow: 0 0 0 4px rgba(255, 208, 64, .55); border-color: #fff0a0; } }
button.hl { animation: hlPulse 1.1s ease-in-out infinite; border-color: var(--gold); }
.brief.narr .say { font-style: italic; color: #e8d8ff; }
.settings { width: min(94vw, 600px); }
.optrow { display: flex; gap: 10px; align-items: center; justify-content: space-between; text-align: left; border-bottom: 1px dashed var(--line); padding: 8px 0; flex-wrap: wrap; }
.optrow .ol { display: flex; flex-direction: column; min-width: 0; flex: 1 1 200px; }
.optrow .ol small { color: var(--muted); font-size: 12px; }
.optrow .ob { display: flex; gap: 6px; flex-wrap: wrap; }
.optrow .ob button { min-width: 64px; min-height: 44px; }
@media (orientation: landscape) and (max-height: 540px) {
  #frozen { font-size: 12px; bottom: 4px; } #frozen button { min-height: 36px; font-size: 12px; }
  .settings { padding: 10px 14px; } .optrow { padding: 4px 0; } .optrow .ob button { min-height: 40px; }
}
