[hidden] { display: none !important; }
html, body { margin: 0; }
:root { padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
/* Layout: one chunky game column on a deep-teal chain-pattern field; thick ink outlines + hard drop shadows.
   Deliberately single-theme (a game screen), so colors are set once. */
:root {
  --field: #0d5b5d;
  --field-deep: #083f41;
  --ink: #1c1633;
  --card: #fffaf0;
  --paper: #ffffff;
  --sun: #ffcf33;
  --coral: #ff5b4a;
  --mint: #2fd4a3;
  --on-field: #effffa;
  --muted: #6b6480;
  --line: 3px solid var(--ink);
  --pop: 0 5px 0 var(--ink);
  --font-display: "Dela Gothic One", "M PLUS Rounded 1c", "Hiragino Sans", sans-serif;
  --font-body: "M PLUS Rounded 1c", "Hiragino Maru Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html { background: var(--field-deep); }
body {
  background-color: var(--field);
  background-image:
    radial-gradient(120% 70% at 50% 0%, rgba(255,255,255,0.10), transparent 60%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='72' height='72'%3E%3Cg fill='none' stroke='white' stroke-opacity='.07' stroke-width='4'%3E%3Crect x='8' y='24' width='28' height='15' rx='7.5' transform='rotate(-32 22 31)'/%3E%3Crect x='27' y='33' width='28' height='15' rx='7.5' transform='rotate(-32 41 40)'/%3E%3C/g%3E%3C/svg%3E");
  color: var(--ink);
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 15px;
  line-height: 1.6;
  min-height: 100%;
}
.wrap {
  max-width: 600px;
  margin: 0 auto;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 18px 56px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 3px; border-radius: 10px; }

/* Top bar */
.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.logo { display: flex; align-items: center; gap: 10px; margin: 0; min-width: 0; }
.logo svg { width: 46px; height: 46px; flex: none; filter: drop-shadow(0 4px 0 var(--ink)); }
.logo h1 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(24px, 6.6vw, 32px);
  line-height: 1.1;
  color: var(--card);
  text-shadow: 0 4px 0 var(--ink);
  letter-spacing: 0.02em;
}
.me-chip {
  display: inline-flex; align-items: center; gap: 8px;
  background: var(--card); border: var(--line); border-radius: 999px;
  padding: 5px 12px 5px 6px; box-shadow: 0 3px 0 var(--ink);
  font-weight: 800; font-size: 14px; max-width: 100%;
}
.me-chip .av { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--ink); display: grid; place-items: center; font-size: 13px; background: var(--sun); flex: none; }
.me-chip span.n { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topr { display: flex; gap: 8px; align-items: center; min-width: 0; }
.snd { background: var(--field-deep); color: var(--on-field); border: 2.5px solid var(--ink); border-radius: 999px; padding: 5px 12px; font-weight: 800; font-size: 13px; }
.snd[aria-pressed="false"] { opacity: 0.7; text-decoration: line-through; }
@keyframes shake { 0%, 100% { transform: translateX(0); } 20% { transform: translateX(-7px); } 40% { transform: translateX(6px); } 60% { transform: translateX(-4px); } 80% { transform: translateX(2px); } }
#fGuess.shake { animation: shake 0.35s ease; }
#fGuess.shake input { border-color: #e0281c; box-shadow: 0 0 0 4px rgba(224, 40, 28, 0.25); }

/* Rooms */
.rooms {
  display: grid; grid-template-columns: 1fr 1fr; gap: 0;
  background: var(--field-deep); border: var(--line); border-radius: 16px; padding: 4px;
}
.rooms button {
  border: none; background: transparent; color: var(--on-field);
  border-radius: 11px; padding: 9px 8px; font-weight: 800; font-size: 15px;
}
.rooms button[aria-selected="true"] { background: var(--sun); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(28,22,51,0.25); }

/* Cards */
.card { background: var(--card); border: var(--line); border-radius: 22px; box-shadow: var(--pop); }

/* Record board */
.board { display: grid; grid-template-columns: auto 1fr; gap: 4px 18px; padding: 14px 18px 16px; align-items: center; }
.board .lbl { font-size: 12px; font-weight: 800; letter-spacing: 0.1em; color: var(--muted); }
.big {
  font-family: var(--font-display); font-weight: 400; font-size: 76px; line-height: 0.95;
  font-variant-numeric: tabular-nums; display: flex; align-items: baseline; gap: 6px;
}
.big small { font-family: var(--font-body); font-size: 15px; font-weight: 800; }
.big.bump { animation: bump 0.5s cubic-bezier(.3,1.6,.5,1); }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25) rotate(-4deg); color: var(--coral); } 100% { transform: scale(1); } }
.board .side { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.best { font-weight: 800; font-size: 14px; }
.best b { font-family: var(--font-display); font-weight: 400; font-size: 20px; }
.goal { display: inline-block; justify-self: start; align-self: flex-start; background: var(--sun); border: 2.5px solid var(--ink); border-radius: 999px; padding: 1px 12px; font-weight: 800; font-size: 13px; font-variant-numeric: tabular-nums; }
#xHandle { margin: 0 2px; }
.fuse { display: flex; flex-direction: column; gap: 4px; }
.fuse .t { font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums; }
.fuse .bar { height: 12px; border: 2.5px solid var(--ink); border-radius: 99px; overflow: hidden; background: #fff; }
.fuse .bar i { display: block; height: 100%; background: var(--mint); transition: width 0.5s linear; }
.fuse.hot .bar i { background: var(--coral); }
.fuse.hot .t { color: var(--coral); }

/* Stage */
.stage { padding: 16px; display: flex; flex-direction: column; gap: 14px; }
.status {
  display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 15px;
  background: var(--ink); color: var(--card); border-radius: 12px; padding: 8px 12px;
}
.status .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--mint); flex: none; }
.status.live .dot { background: var(--coral); animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.2; } }
.frame {
  position: relative; width: 100%; max-width: 100%; aspect-ratio: 1 / 1;
  background: var(--paper); border: var(--line); border-radius: 16px; overflow: hidden;
  display: grid; place-items: center;
}
.frame img { width: 100%; height: 100%; object-fit: contain; display: block; }
.frame .tag {
  position: absolute; left: 10px; top: 10px; background: var(--sun); border: 2.5px solid var(--ink);
  border-radius: 10px; padding: 2px 10px; font-weight: 800; font-size: 13px;
}
.nopic { text-align: center; padding: 24px; display: flex; flex-direction: column; gap: 4px; align-items: center; font-weight: 700; }
.nopic .w { font-family: var(--font-display); font-size: 40px; line-height: 1.2; }
.qline { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.qword { font-family: var(--font-display); font-size: 28px; letter-spacing: 0.12em; line-height: 1.1; }
.by { font-size: 13px; font-weight: 700; color: var(--muted); }
.by b { color: var(--ink); }

.panel { display: flex; flex-direction: column; gap: 12px; }
.panel h2 { margin: 0; font-size: 18px; font-weight: 800; line-height: 1.4; text-wrap: balance; }
.panel p { margin: 0; }
.hint { color: var(--muted); font-size: 13px; font-weight: 700; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 2.5px solid var(--ink); border-radius: 999px; padding: 2px 10px; font-weight: 800; font-size: 13px; background: #fff; }
.chip.sun { background: var(--sun); }

.btn {
  border: var(--line); border-radius: 16px; padding: 12px 18px;
  font-weight: 800; font-size: 17px; background: var(--sun); color: var(--ink);
  box-shadow: var(--pop); transition: transform 0.06s ease, box-shadow 0.06s ease;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.btn[disabled] { opacity: 0.55; cursor: not-allowed; }
.btn.coral { background: var(--coral); color: #fff; }
.btn.mint { background: var(--mint); }
.btn.plain { background: #fff; font-size: 14px; padding: 9px 14px; box-shadow: 0 3px 0 var(--ink); }
.btn.wide { width: 100%; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: stretch; }
.row > input { flex: 1 1 170px; min-width: 0; }
input[type="text"] {
  border: var(--line); background: #fff; border-radius: 14px; padding: 11px 14px; font-size: 18px; font-weight: 700;
}
input[type="text"]:focus { outline: none; box-shadow: 0 0 0 4px var(--sun); }
.buzz { font-family: var(--font-display); font-weight: 400; font-size: 20px; padding-inline: 22px; }

.timer { display: flex; align-items: center; gap: 10px; }
.timer .bar { flex: 1; height: 16px; border: var(--line); border-radius: 99px; background: #fff; overflow: hidden; }
.timer .bar i { display: block; height: 100%; background: var(--mint); transition: width 0.25s linear; }
.timer .t { font-family: var(--font-display); font-size: 22px; min-width: 2.6em; text-align: right; font-variant-numeric: tabular-nums; }
.timer.low .bar i { background: var(--coral); }
.timer.low .t { color: var(--coral); }

.solved {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  background: var(--mint); border: var(--line); border-radius: 14px; padding: 8px 14px; font-weight: 800;
}
.solved .w { font-family: var(--font-display); font-weight: 400; font-size: 24px; }
.nextc {
  font-family: var(--font-display); font-size: 40px; line-height: 1; width: 68px; height: 68px;
  display: inline-grid; place-items: center; background: var(--sun); border: var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--ink);
}
.odai { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.odai .w { font-family: var(--font-display); font-size: 30px; line-height: 1.1; }

.feed { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px; }
.feed li { border: 2.5px solid var(--ink); border-radius: 12px; padding: 3px 10px; font-size: 13px; font-weight: 700; background: #fff; max-width: 100%; overflow-wrap: anywhere; }
.feed li.ok { background: var(--mint); }
.feed li.ng { color: var(--muted); }
.feed li b { color: var(--ink); }
.feed li .x { color: #e0281c; font-weight: 800; }
.feed li.ng { color: var(--ink); }
.feedbox { display: flex; flex-direction: column; gap: 6px; }
.livewrap { position: relative; }
#liveCv { width: 100%; height: 100%; display: block; background: var(--paper); border: var(--line); border-radius: 16px; }
.livebadge { position: absolute; top: 10px; left: 10px; background: var(--coral); color: #fff; border: 2.5px solid var(--ink); border-radius: 10px; padding: 1px 10px; font-weight: 800; font-size: 12px; letter-spacing: 0.08em; }
.foot { text-align: center; font-size: 13px; font-weight: 700; }
.foot a, .nick-note a { color: inherit; }
.foot a { color: var(--on-field); }
.report { border: none; background: none; padding: 0 2px; font: inherit; font-size: 12px; font-weight: 700; color: var(--muted); text-decoration: underline; cursor: pointer; }
.hiddenpic { width: 100%; aspect-ratio: 1 / 1; display: grid; place-items: center; background: #f1eee6; border: 2.5px solid var(--ink); border-radius: 10px; color: var(--muted); font-weight: 800; font-size: 13px; text-align: center; padding: 8px; }
.check { margin: 0; border: 2.5px solid var(--ink); border-radius: 12px; padding: 8px 12px; font-weight: 800; font-size: 14px; background: #fff; }
.check.wait { background: #fff3c4; }
.check.bad { background: #ffe1dd; color: #b3170d; }
.feedhead { font-weight: 800; font-size: 14px; }
.feedhead span { font-weight: 700; font-size: 13px; color: var(--muted); margin-left: 4px; }

/* Canvas */
.canvas-wrap { width: 100%; max-width: 100%; aspect-ratio: 1 / 1; }
#cv { width: 100%; height: 100%; display: block; background: var(--paper); border: var(--line); border-radius: 16px; touch-action: none; cursor: crosshair; }
.tools { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.sw { width: 32px; height: 32px; border-radius: 50%; border: 2.5px solid var(--ink); padding: 0; }
.sw[aria-pressed="true"] { box-shadow: 0 0 0 3px var(--card), 0 0 0 6px var(--ink); }
.sz, .tool { height: 34px; border: 2.5px solid var(--ink); background: #fff; border-radius: 10px; font-weight: 800; font-size: 13px; }
.sz { width: 38px; display: grid; place-items: center; padding: 0; }
.sz i { display: block; border-radius: 50%; background: var(--ink); }
.tool { padding: 0 10px; }
.sz[aria-pressed="true"], .tool[aria-pressed="true"] { background: var(--sun); }

/* Nickname */
.nick-note { font-size: 13px; font-weight: 700; background: #fff3c4; border: 2.5px solid var(--ink); border-radius: 12px; padding: 8px 12px; }

/* History */
.sec h2 { margin: 0 0 10px; font-family: var(--font-display); font-weight: 400; font-size: 20px; color: var(--card); text-shadow: 0 3px 0 var(--ink); display: flex; gap: 10px; align-items: baseline; }
.sec h2 small { font-family: var(--font-body); font-weight: 800; font-size: 13px; text-shadow: none; color: var(--on-field); opacity: 0.85; }
.hist { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.hist li { background: var(--card); border: var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); padding: 8px; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.hist img { width: 100%; aspect-ratio: 1 / 1; object-fit: contain; background: var(--paper); border: 2.5px solid var(--ink); border-radius: 10px; display: block; }
.hist .w { font-family: var(--font-display); font-size: 19px; line-height: 1.2; display: flex; gap: 6px; align-items: baseline; }
.hist .n { font-family: var(--font-body); font-size: 12px; font-weight: 800; color: var(--muted); font-variant-numeric: tabular-nums; }
.hist .who { font-size: 12px; font-weight: 700; color: var(--muted); overflow-wrap: anywhere; }
.hist .who b { color: var(--ink); }
.empty { color: var(--on-field); font-weight: 700; font-size: 14px; padding: 14px; border: 2.5px dashed rgba(239,255,250,0.5); border-radius: 16px; margin: 0; }

.past { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.past li { display: flex; justify-content: space-between; gap: 10px; padding: 8px 14px; background: var(--card); border: var(--line); border-radius: 12px; font-size: 14px; font-weight: 700; }
.past li b { font-family: var(--font-display); font-weight: 400; }
.past li span { color: var(--muted); font-variant-numeric: tabular-nums; }

details.rules { padding: 12px 18px; }
details.rules summary { font-weight: 800; cursor: pointer; font-size: 16px; }
details.rules ol { margin: 10px 0 0; padding-left: 1.3em; display: flex; flex-direction: column; gap: 6px; font-size: 14px; }
details.rules .note { margin: 10px 0 0; font-size: 13px; color: var(--muted); }
.solo { display: flex; gap: 8px; align-items: center; font-size: 13px; font-weight: 700; color: var(--muted); }
.notice { font-size: 13px; font-weight: 700; color: var(--muted); border: 2.5px dashed var(--ink); border-radius: 12px; padding: 10px 14px; margin: 0; }

/* Pop-up moments */
.pop {
  position: fixed; left: 50%; top: 38%; z-index: 30; transform: translate(-50%, -50%);
  max-width: calc(100% - 32px); width: max-content;
  background: var(--sun); border: 4px solid var(--ink); border-radius: 24px; box-shadow: 0 8px 0 var(--ink);
  padding: 16px 26px; text-align: center; pointer-events: none;
  animation: popin 0.45s cubic-bezier(.3,1.6,.5,1);
}
.pop.mint { background: var(--mint); }
.pop.coral { background: var(--coral); color: #fff; }
.pop .h { font-family: var(--font-display); font-size: clamp(28px, 9vw, 42px); line-height: 1.15; }
.pop .s { font-weight: 800; font-size: 16px; overflow-wrap: anywhere; }
@keyframes popin { 0% { transform: translate(-50%, -50%) scale(0.4) rotate(-8deg); opacity: 0; } 100% { transform: translate(-50%, -50%) scale(1) rotate(0); opacity: 1; } }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(16px + env(safe-area-inset-bottom, 0px)); z-index: 31;
  max-width: calc(100% - 32px); background: var(--ink); color: var(--card);
  padding: 10px 16px; border-radius: 14px; font-size: 14px; font-weight: 700; border: 2px solid var(--card);
}
@media (prefers-reduced-motion: reduce) {
  *, .pop { animation: none !important; transition: none !important; }
}

/* 2〜4人で遊ぶ への入口 */
.partylink { display: block; text-align: center; background: var(--card); border: var(--line); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); padding: 10px 14px; font-weight: 800; color: var(--ink); text-decoration: none; }
.partylink:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--ink); }
.topr { flex-wrap: wrap; justify-content: flex-end; }
