* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: #2b2140; color: #3a2a1a; font-family: "Hiragino Maru Gothic ProN", "Rounded Mplus 1c", "Yu Gothic", "Meiryo", system-ui, sans-serif; overflow: hidden; -webkit-user-select: none; user-select: none; }
#app { position: relative; width: 100%; height: 100%; background: radial-gradient(circle at 50% 30%, #6a4fa0 0%, #2b2140 75%); }
.screen { display: none; position: absolute; inset: 0; align-items: center; justify-content: center; padding: 12px; }
.screen.active { display: flex; }
button { font: inherit; cursor: pointer; border: none; border-radius: 12px; padding: 8px 14px; background: #ffd25e; color: #4a2c00; font-weight: bold; box-shadow: 0 3px 0 #c48a12; transition: transform .05s; }
button:active { transform: translateY(2px); box-shadow: 0 1px 0 #c48a12; }
button:disabled { opacity: .5; cursor: default; }
button.big { font-size: 1.15em; padding: 10px 22px; }
button.ghost-btn { background: #fff3d6; box-shadow: 0 3px 0 #cdb58a; }
input, select { font: inherit; padding: 9px 12px; border-radius: 10px; border: 2px solid #d9b980; background: #fffaf0; color: #3a2a1a; min-width: 0; }
h1 { font-size: 3.2em; margin: 0; color: #ffd25e; text-shadow: 0 4px 0 #8a4a00, 0 0 18px rgba(255,180,60,.6); letter-spacing: .06em; }
h2 { margin: 0 0 12px; }
h3 { margin: 6px 0; font-size: 1em; }
.title-box { text-align: center; display: flex; flex-direction: column; gap: 12px; align-items: center; width: min(520px, 100%); }
#title-art { width: 100%; max-width: 520px; height: auto; }
.sub { color: #f6e7ff; margin: 0; }
.conn { color: #cbb8e8; font-size: .85em; margin: 0; }
.panel { background: #fff6e2; border-radius: 18px; padding: 18px; width: min(560px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 8px 0 #b08a50, 0 12px 30px rgba(0,0,0,.4); }
.panel.wide { width: min(900px, 100%); }
.row { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.create { display: flex; gap: 8px; flex-wrap: wrap; }
.create input { flex: 1; }
.room-list { list-style: none; padding: 0; margin: 12px 0 0; display: flex; flex-direction: column; gap: 6px; min-height: 80px; }
.room-list li { display: flex; align-items: center; gap: 10px; background: #fff; padding: 10px 12px; border-radius: 12px; border: 2px solid #f0d9a8; }
.room-list li .nm { flex: 1; font-weight: bold; }
.room-list .tag { font-size: .8em; background: #ffe7a6; padding: 2px 8px; border-radius: 8px; }
.room-list .empty { justify-content: center; color: #a08868; border-style: dashed; }
.room-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 8px; }
.mode-btn { background: #fff3d6; box-shadow: 0 3px 0 #cdb58a; }
.mode-btn.on { background: #ff9d5c; color: #fff; box-shadow: 0 3px 0 #b85a1e; }
.room-body { display: grid; grid-template-columns: 1fr 1.3fr; gap: 16px; }
@media (max-width: 700px) { .room-body { grid-template-columns: 1fr; } }
.members { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: 5px; }
.members li { display: flex; align-items: center; gap: 8px; background: #fff; padding: 5px 8px; border-radius: 10px; border: 2px solid #f0d9a8; }
.members li.t0 { border-color: #ff8a8a; } .members li.t1 { border-color: #7fb2ff; }
.members canvas { width: 34px; height: 34px; }
.members .nm { flex: 1; font-weight: bold; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.members .st { font-size: .8em; padding: 2px 6px; border-radius: 6px; background: #eee; }
.members .st.ok { background: #8be08b; }
.members .st.host { background: #ffd25e; }
.members .x { padding: 2px 8px; font-size: .8em; background: #ffd0d0; box-shadow: 0 2px 0 #c99; }
.members .sw { padding: 2px 8px; font-size: .8em; background: #e0e8ff; box-shadow: 0 2px 0 #99a; }
.team-btn.red { background: #ff8a8a; box-shadow: 0 3px 0 #c44; color: #fff; }
.team-btn.blue { background: #7fb2ff; box-shadow: 0 3px 0 #3a6fd0; color: #fff; }
.team-btn.on { outline: 3px solid #4a2c00; }
.char-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.char-grid button { padding: 4px; background: #fff; box-shadow: 0 3px 0 #e0c99a; border: 2px solid #f0d9a8; display: flex; flex-direction: column; align-items: center; font-size: .72em; }
.char-grid button.on { border-color: #ff7a2e; background: #fff0dc; }
.char-grid canvas { width: 100%; max-width: 56px; aspect-ratio: 1; }
.char-info { margin-top: 8px; font-size: .88em; background: #fff; border-radius: 10px; padding: 8px 10px; min-height: 60px; }
.bar { display: inline-block; height: 8px; background: #ffb547; border-radius: 4px; vertical-align: middle; }
.chat { margin-top: 12px; }
.chat-log { height: 90px; overflow-y: auto; background: #fff; border-radius: 10px; padding: 6px 10px; font-size: .88em; border: 2px solid #f0d9a8; margin-bottom: 6px; }
.chat input { width: 100%; }

/* ゲーム画面 */
#scr-game { flex-direction: column; padding: 6px; gap: 6px; justify-content: flex-start; }
#hud-top { display: flex; justify-content: center; width: 100%; }
#hud-time { font-size: 1.6em; font-weight: bold; color: #fff; background: rgba(0,0,0,.35); padding: 2px 18px; border-radius: 12px; font-variant-numeric: tabular-nums; }
#stage { flex: 1; width: 100%; display: flex; align-items: center; justify-content: center; min-height: 0; }
#cv { border-radius: 12px; box-shadow: 0 6px 24px rgba(0,0,0,.5); image-rendering: auto; touch-action: none; }
#hud-me { color: #fff; display: flex; gap: 14px; align-items: center; justify-content: center; flex-wrap: wrap; font-weight: bold; background: rgba(0,0,0,.35); padding: 6px 14px; border-radius: 12px; min-height: 40px; }
#hud-me .gauge { width: 130px; height: 14px; background: rgba(255,255,255,.2); border-radius: 7px; overflow: hidden; display: inline-block; vertical-align: middle; }
#hud-me .gauge i { display: block; height: 100%; background: linear-gradient(90deg, #ffd25e, #ff6a2e); }
#hud-me .gauge.full i { background: linear-gradient(90deg, #ff6a2e, #ff2e2e); animation: pulse .5s infinite alternate; }
@keyframes pulse { from { filter: brightness(1); } to { filter: brightness(1.5); } }
#touch { display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 190px; pointer-events: none; }
body.touch #touch { display: block; }
#dpad { position: absolute; left: 14px; bottom: 14px; width: 160px; height: 160px; pointer-events: auto; }
#dpad .d { position: absolute; width: 56px; height: 56px; font-size: 1.4em; opacity: .8; padding: 0; background: #fff3d6; }
#dpad .up { left: 52px; top: 0; } #dpad .down { left: 52px; bottom: 0; } #dpad .left { left: 0; top: 52px; } #dpad .right { right: 0; top: 52px; }
#dpad .d.on, .act.on { filter: brightness(.8); transform: translateY(2px); }
.act { position: absolute; right: 22px; bottom: 34px; width: 104px; height: 104px; border-radius: 50%; font-size: 1.1em; pointer-events: auto; opacity: .85; background: #ff9d5c; color: #fff; box-shadow: 0 4px 0 #b85a1e; }
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(20,10,40,.65); z-index: 20; padding: 12px; }
.overlay.hidden, .hidden { display: none !important; }
.help-box, .result-box { background: #fff6e2; border-radius: 18px; padding: 20px; width: min(640px, 100%); max-height: 100%; overflow: auto; box-shadow: 0 8px 0 #b08a50; }
.help-box li { margin-bottom: 8px; line-height: 1.5; }
.result-box { text-align: center; }
.result-box h2 { font-size: 2em; color: #ff7a2e; }
.result-box table { width: 100%; border-collapse: collapse; margin: 10px 0; }
.result-box td, .result-box th { padding: 6px; border-bottom: 1px solid #f0d9a8; }
.result-box tr.win td { background: #fff0b8; font-weight: bold; }
.toast { position: absolute; top: 16px; left: 50%; transform: translateX(-50%); background: #3a2a1a; color: #fff; padding: 10px 18px; border-radius: 12px; z-index: 50; box-shadow: 0 4px 12px rgba(0,0,0,.4); }

.hint-small { color: #8a7050; font-size: .85em; margin: 6px 0 0; }

.my-stats { color: #ffd25e; font-weight: bold; margin: 0; min-height: 1.2em; }
.char-grid small { color: #b0682a; font-size: .9em; }
.char-info .trait { color: #e0602a; }
.result-box { position: relative; overflow: hidden; }
.result-box .rating { font-size: 1.05em; margin: 4px 0 8px; }
.result-box .rating .num { font-size: 1.5em; color: #ff7a2e; }
.result-box .rating .plus { color: #2aa84a; font-weight: bold; }
.result-box .rating .minus { color: #c84a4a; font-weight: bold; }
.result-box .rating .ttl { font-weight: bold; color: #8a4ad0; }
.awards { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 6px; margin: 6px 0; text-align: left; }
.award { display: flex; gap: 8px; align-items: center; background: #fff; border: 2px solid #f0d9a8; border-radius: 10px; padding: 4px 8px; animation: pop .35s ease-out both; }
.award:nth-child(2) { animation-delay: .1s } .award:nth-child(3) { animation-delay: .2s } .award:nth-child(4) { animation-delay: .3s } .award:nth-child(5) { animation-delay: .4s } .award:nth-child(6) { animation-delay: .5s }
.award.mine { border-color: #ff9d5c; background: #fff0dc; }
.award canvas { width: 36px; height: 36px; flex: none; }
.award b { color: #e0602a; }
.award small { display: block; color: #8a7050; font-size: .78em; }
@keyframes pop { from { transform: scale(.6); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.confetti-layer { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.confetti-layer i { position: absolute; top: -12px; width: 8px; height: 12px; border-radius: 2px; animation: fall linear infinite; opacity: .9; }
@keyframes fall { to { top: 105%; transform: rotate(720deg) translateX(30px); } }

.seg { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; justify-content: center; margin-top: 8px; }
.seg span { font-size: .85em; margin-right: 4px; color: inherit; }
#quick-level span { color: #f6e7ff; }
.seg button { padding: 4px 10px; font-size: .88em; background: #fff3d6; box-shadow: 0 2px 0 #cdb58a; }
.seg button.on { background: #ff9d5c; color: #fff; box-shadow: 0 2px 0 #b85a1e; }
.kc-table { width: 100%; border-collapse: collapse; }
.kc-table th { text-align: left; font-size: .92em; padding: 4px 6px; }
.kc-table td { padding: 3px; }
.kc-slot { width: 100%; min-width: 80px; background: #fff; box-shadow: 0 2px 0 #e0c99a; border: 2px solid #f0d9a8; font-size: .9em; }
.kc-slot.listening { background: #ffe7a6; border-color: #ff7a2e; animation: pulse .5s infinite alternate; }
