:root {
  color-scheme:dark;
  --bg:#101a23;
  --panel:#17232e;
  --line:#2a3a46;
  --text:#e6eced;
  --muted:#9bafb9;
  --accent:#acd9b0;
  --gold:#d4b779;
  font-family:"Yu Gothic UI","Yu Gothic",Meiryo,sans-serif;
  font-size:14px;
  color:var(--text);
  background:var(--bg)
}

* {
  box-sizing:border-box
}

body {
  margin:0
}

button,select,textarea,input {
  font:inherit
}

button,a,select,input {
  touch-action:manipulation
}

button,select {
  border:1px solid var(--line);
  border-radius:7px;
  background:#1a2a36;
  color:var(--text);
  min-height:40px;
  padding:8px 13px
}

button {
  cursor:pointer;
  transition:background .15s,border-color .15s
}

button:hover:not(:disabled),a:hover {
  background:#2b414d
}

button:disabled,select:disabled {
  opacity:.4;
  cursor:default
}

button.accent {
  background:var(--accent);
  color:#14261f;
  border-color:var(--accent);
  font-weight:700
}

button.accent:hover {
  background:#c7e9c9
}

a {
  color:inherit;
  text-decoration:none
}

button:focus-visible,a:focus-visible,input:focus-visible,select:focus-visible,summary:focus-visible,textarea:focus-visible {
  outline:2px solid var(--accent);
  outline-offset:4px
}

h1,h2,p {
  margin:0
}

h2 {
  font-size:14px;
  font-weight:600
}

button svg {
  width:20px;
  height:20px;
  vertical-align:middle
}

.app-header {
  height:82px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  padding:0 32px;
  border-bottom:1px solid var(--line);
  gap:20px
}

.brand {
  display:flex;
  gap:11px;
  align-items:center;
  font-weight:700;
  letter-spacing:.07em
}

.brand-mark {
  width:36px;
  height:42px;
  border-radius:6px;
  background:#e2e5d6;
  border-bottom:5px solid #6b997b;
  color:#233c33;
  display:grid;
  place-items:center;
  font-size:22px
}

.brand small {
  display:block;
  font-size:9px;
  color:var(--muted);
  letter-spacing:.19em;
  margin-top:4px
}

.header-title {
  display:flex;
  align-items:center;
  gap:12px
}

.header-title h1 {
  font-size:16px;
  font-weight:500
}

.badge {
  font-size:10px;
  padding:4px 7px;
  border:1px solid #64745d;
  border-radius:4px;
  color:var(--accent)
}

nav {
  display:flex;
  gap:16px;
  align-items:center
}

nav a {
  font-size:12px;
  padding:10px;
  border-radius:6px
}

.workspace {
  display:grid;
  grid-template-columns:minmax(0,1fr) 292px;
  max-width:1760px;
  margin:0 auto;
  padding:25px 28px 16px;
  gap:26px
}

.viewer-column {
  min-width:0
}

.table-toolbar {
  min-height:58px;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px
}

.table-toolbar>div:first-child {
  display:flex;
  align-items:baseline;
  gap:12px
}

.eyebrow {
  font:10px ui-monospace,monospace;
  letter-spacing:.16em;
  color:var(--muted)
}

#round-title {
  font-size:21px;
  font-weight:600
}

.muted {
  font-size:12px;
  color:var(--muted)
}

.view-buttons {
  display:flex;
  border:1px solid var(--line);
  border-radius:7px;
  padding:3px;
  gap:2px
}

.view-buttons button {
  border:0;
  min-height:30px;
  padding:5px 11px;
  font-size:12px;
  background:transparent
}

.view-buttons button[aria-pressed=true] {
  background:#314738;
  color:#c5e1c3
}

.stage {
  height:clamp(380px,calc(100dvh - 308px),850px);
  min-height:380px;
  position:relative;
  border:1px solid #30434b;
  border-radius:14px;
  overflow:hidden;
  background:radial-gradient(ellipse at 50% 35%,#304345,#17282e 60%,#122029)
}

#table-canvas {
  display:block;
  width:100%;
  height:100%;
  touch-action:none
}

.stage-caption {
  position:absolute;
  top:19px;
  left:21px;
  display:flex;
  align-items:center;
  gap:8px;
  font-size:11px;
  color:#b4c8c7;
  pointer-events:none;
  max-width:75%
}

.live-dot {
  width:6px;
  height:6px;
  background:var(--accent);
  border-radius:50%
}

.stage-hint {
  position:absolute;
  bottom:15px;
  left:0;
  right:0;
  text-align:center;
  font-size:10px;
  letter-spacing:.05em;
  color:#b0c4c4;
  pointer-events:none
}

.scene-status {
  position:absolute;
  inset:40% 10% auto;
  text-align:center;
  padding:20px;
  background:#142530e8;
  border:1px solid var(--line);
  border-radius:10px;
  line-height:1.8
}

.transport {
  padding:19px 6px 0
}

.seek-heading {
  display:flex;
  align-items:center;
  justify-content:space-between;
  font-size:12px
}

.seek-heading strong {
  font-weight:500
}

.seek-heading output {
  color:var(--muted);
  font:12px ui-monospace,monospace
}

#seek {
  width:100%;
  height:25px;
  margin:8px 0 12px;
  accent-color:var(--accent);
  cursor:pointer
}

.transport-row {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:12px
}

.round-jump {
  display:flex;
  gap:6px
}

.round-jump button {
  font-size:11px;
  padding:8px
}

.playback-buttons {
  display:flex;
  align-items:center;
  gap:8px
}

.playback-buttons button {
  width:42px;
  padding:8px;
  background:transparent;
  border:0
}

.playback-buttons .play {
  width:52px;
  height:48px;
  background:var(--accent);
  color:#153226;
  border-radius:13px
}

.playback-buttons .play:hover:not(:disabled) {
  background:#c6e6c5
}

.speed-label {
  font-size:11px;
  color:var(--muted);
  display:flex;
  align-items:center;
  gap:7px
}

.speed-label select {
  font-size:12px;
  min-height:36px
}

.sidebar {
  padding:15px 19px 8px;
  background:var(--panel);
  border:1px solid var(--line);
  border-radius:12px;
  align-self:start
}

.sidebar section {
  padding:18px 0;
  border-bottom:1px solid var(--line)
}

.sidebar section:first-child {
  padding-top:2px
}

.match-info h2 {
  font-size:18px;
  line-height:1.6;
  margin:9px 0 6px;
  overflow-wrap:anywhere
}

.match-info p {
  line-height:1.7
}

.field-label {
  display:block;
  font-size:11px;
  color:var(--muted);
  margin:18px 0 7px
}

#round-select {
  width:100%;
  font-size:12px
}

.section-heading {
  display:flex;
  justify-content:space-between;
  align-items:center;
  gap:4px;
  margin-bottom:13px
}

.section-heading .muted {
  font-size:10px
}

.players {
  display:flex;
  flex-direction:column;
  gap:7px
}

.player {
  display:grid;
  grid-template-columns:28px minmax(0,1fr) auto;
  gap:8px;
  align-items:center;
  text-align:left;
  width:100%;
  padding:10px 8px;
  background:transparent;
  border:1px solid transparent
}

.player[aria-pressed=true] {
  background:#233a3d;
  border-color:#5a8277
}

.player.active .wind {
  box-shadow:0 0 0 2px var(--gold)
}

.wind {
  width:25px;
  height:28px;
  display:grid;
  place-items:center;
  border:1px solid #536567;
  border-radius:5px;
  font-size:12px;
  color:var(--accent)
}

.player-name {
  font-size:12px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap
}

.player-score {
  font:15px ui-monospace,monospace
}

.player small {
  display:block;
  font-size:9px;
  color:var(--gold);
  margin-top:3px
}

.dora {
  display:flex;
  gap:5px;
  min-height:43px
}

.dora img {
  width:28px;
  height:40px;
  object-fit:contain;
  background:#f7f4e7;
  border:2px solid #e7e4d9;
  border-radius:4px;
  box-shadow:0 3px 0 #abb6a5
}

.dora-back {
  width:28px;
  height:40px;
  border:2px solid #cfb473;
  border-radius:4px;
  background:#a98c45;
  box-shadow:0 3px 0 #77764d
}

.settings h2 {
  margin-bottom:16px
}

.settings label {
  display:flex;
  justify-content:space-between;
  align-items:center;
  font-size:12px;
  min-height:36px
}

.settings input {
  accent-color:var(--accent);
  width:18px;
  height:18px
}

.legend {
  font-size:10px;
  color:var(--muted);
  line-height:1.8;
  margin-top:10px
}

.legend i {
  display:inline-block;
  width:7px;
  height:7px;
  border-radius:2px;
  background:var(--gold);
  margin-right:3px
}

.legend span {
  padding:0 3px
}

.share-button {
  width:100%;
  font-size:12px;
  margin-top:18px
}

.notice {
  font-size:11px;
  line-height:1.7;
  color:var(--gold);
  margin:10px 0;
  overflow-wrap:anywhere
}

.sidebar-foot {
  font-size:10px;
  text-align:center;
  color:#91a7ac;
  letter-spacing:.1em;
  margin:12px 0
}

.text-view {
  font-size:11px;
  color:var(--muted);
  margin-top:20px;
  line-height:1.8
}

.text-view summary {
  cursor:pointer
}

.text-view pre {
  font:12px/1.9 inherit;
  white-space:pre-wrap;
  overflow-wrap:anywhere
}

.result h2 {
  font-size:19px;
  color:var(--gold);
  margin-bottom:8px
}

.result p {
  font-size:12px;
  line-height:1.8
}

.result-delta {
  display:flex;
  justify-content:space-between;
  font-size:11px;
  margin-top:9px;
  gap:8px
}

.positive {
  color:var(--accent)
}

.negative {
  color:#f5a4a0
}

dialog {
  color:var(--text);
  background:var(--panel);
  border:1px solid #45565d;
  border-radius:15px;
  padding:26px;
  width:min(580px,calc(100% - 28px));
  max-height:90dvh;
  box-shadow:0 24px 100px #0009
}

dialog::backdrop {
  background:#050e17bd;
  backdrop-filter:blur(5px)
}

.dialog-heading {
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom:16px
}

.dialog-heading h2,dialog>h2 {
  font-size:20px
}

.dialog-heading button {
  background:transparent;
  border:0;
  font-size:24px
}

dialog p {
  line-height:1.8;
  margin-bottom:18px
}

dialog label {
  display:block;
  font-size:12px;
  margin:15px 0 8px
}

textarea {
  width:100%;
  resize:vertical;
  padding:12px;
  background:#101c26;
  color:var(--text);
  border:1px solid var(--line);
  border-radius:7px;
  font:12px/1.8 ui-monospace,monospace
}

.file-label {
  color:var(--muted)
}

.file-label input {
  display:block;
  width:100%;
  margin-top:9px;
  font-size:12px
}

#import-error {
  color:#f4b1a5;
  font-size:12px;
  margin:15px 0
}

.dialog-actions {
  display:flex;
  justify-content:space-between;
  gap:12px;
  margin-top:20px
}

.sr-only {
  position:absolute;
  width:1px;
  height:1px;
  margin:-1px;
  overflow:hidden;
  clip:rect(0,0,0,0)
}

[hidden] {
  display:none!important
}

@media(min-width:1600px) {
  .workspace {
    grid-template-columns:minmax(0,1fr) 318px;
    gap:32px
  }
  .sidebar {
    padding:20px 24px
  }
  .player {
    padding:13px 9px
  }
}

@media(max-width:1000px) {
  .app-header {
    padding:0 20px;
    height:70px
  }
  .header-title h1 {
    font-size:14px
  }
  .workspace {
    padding:15px;
    gap:16px;
    grid-template-columns:minmax(0,1fr) 250px
  }
  .sidebar {
    padding:14px
  }
  .table-toolbar .eyebrow {
    display:none
  }
  .table-toolbar>div:first-child {
    gap:8px
  }
  #round-title {
    font-size:18px
  }
  #round-meta {
    font-size:10px
  }
  .round-jump button {
    font-size:10px;
    padding:5px
  }
  .playback-buttons {
    gap:2px
  }
  .playback-buttons button {
    width:32px
  }
  .speed-label {
    gap:4px
  }
  .speed-label select {
    padding:6px
  }
  .stage {
    height:calc(100dvh - 290px)
  }
}

@media(max-width:760px) {
  .app-header {
    height:67px;
    padding:0 14px;
    gap:8px
  }
  .brand {
    font-size:12px;
    gap:7px
  }
  .brand small {
    font-size:7px
  }
  .brand-mark {
    width:28px;
    height:34px;
    font-size:18px
  }
  .header-title {
    display:none
  }
  nav {
    gap:4px
  }
  nav button,nav a {
    font-size:11px;
    min-height:38px
  }
  .workspace {
    display:flex;
    flex-direction:column;
    padding:10px;
    gap:18px
  }
  .table-toolbar {
    min-height:53px
  }
  .table-toolbar>div:first-child {
    gap:7px
  }
  .view-buttons button {
    font-size:11px;
    padding:5px 8px
  }
  .stage {
    height:clamp(280px,88vw,620px);
    min-height:0;
    border-radius:10px
  }
  .stage-caption {
    left:12px;
    top:12px;
    font-size:10px
  }
  .stage-hint {
    font-size:9px;
    bottom:9px
  }
  .transport {
    padding:14px 3px 0
  }
  .transport-row {
    gap:5px
  }
  .round-jump {
    gap:2px
  }
  .round-jump button {
    padding:5px;
    font-size:10px
  }
  .playback-buttons {
    gap:2px
  }
  .playback-buttons button {
    width:29px
  }
  .playback-buttons .play {
    width:44px;
    height:44px
  }
  .speed-label {
    font-size:0
  }
  .speed-label select {
    font-size:11px
  }
  .sidebar {
    width:100%;
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:0 18px;
    align-self:stretch;
    padding:16px
  }
  .sidebar .match-info {
    grid-column:1/-1
  }
  .sidebar .match-info h2 {
    font-size:16px
  }
  .match-info .field-label {
    margin-top:12px
  }
  .sidebar .settings,.sidebar .result,.sidebar .share-button,.sidebar .notice,.sidebar .sidebar-foot {
    grid-column:1/-1
  }
  .sidebar .section-heading {
    align-items:start;
    flex-direction:column;
    gap:5px
  }
  .player {
    padding:9px 2px;
    gap:5px;
    grid-template-columns:23px minmax(0,1fr)
  }
  .player-score {
    grid-column:2;
    font-size:14px
  }
  .wind {
    grid-row:1/3;
    width:22px
  }
  .player small {
    display:inline;
    font-size:9px
  }
  .sidebar .dora {
    flex-wrap:wrap;
    gap:4px
  }
  .dora img,.dora-back {
    width:23px;
    height:33px
  }
  .text-view {
    margin-top:14px
  }
  .notice:empty {
    display:none
  }
}

@media(prefers-reduced-motion:reduce) {
  * {
    transition:none!important;
    scroll-behavior:auto!important
  }
}

@media(max-width:380px) {
  .transport-row {
    flex-wrap:wrap;
    justify-content:center;
  }
  .round-jump {
    order:2;
    width:100%;
    justify-content:center;
  }
  .round-jump button {
    min-width:62px;
    white-space:nowrap;
  }
}
.player-avatar{width:32px;height:32px;float:left;margin:2px 8px 0 0;border-radius:6px;object-fit:cover}
.expand-table{display:block;margin:0 0 8px auto;font-size:12px;min-height:32px;padding:5px 12px}
.table-expanded{overflow:hidden}
.table-expanded .app-header,.table-expanded .text-view{display:none}
.table-expanded .workspace{position:fixed;inset:0;max-width:none;display:block;padding:8px 14px;background:var(--bg);z-index:10}
.table-expanded .viewer-column{height:100%;display:grid;grid-template-rows:44px 36px minmax(0,1fr) auto}
.table-expanded .table-toolbar{min-height:0}
.table-expanded .stage{height:100%;min-height:0}
.table-expanded .transport{padding-top:8px}
.table-expanded #seek{margin:4px 0}
.table-expanded .expand-table{margin-bottom:4px}
@media(max-width:760px){.table-toolbar{flex-wrap:wrap}.sidebar>section:has(.players){grid-column:1/-1}.table-expanded .workspace{padding:4px 8px}.table-expanded .viewer-column{grid-template-rows:auto 36px minmax(0,1fr) auto}.table-expanded .table-toolbar{padding-bottom:4px}.table-expanded .round-jump{display:none}}
.table-toolbar{flex-wrap:wrap}
.view-buttons{flex-wrap:wrap}
.table-expanded .viewer-column{grid-template-rows:auto minmax(0,1fr) auto}
.table-expanded .table-toolbar{min-height:44px;padding-bottom:4px}
/* Normal view has two rows; expanded view puts round navigation first. */
.transport{display:grid;grid-template-columns:auto minmax(0,1fr) auto;align-items:center;gap:6px 12px;padding:8px 3px 0}
.transport-row{display:contents}
.transport #seek{grid-column:1/-1;grid-row:1;margin:0;height:28px;min-width:0}
.transport .round-jump{display:flex;grid-column:1;grid-row:2;order:0;width:auto;justify-content:start}
.transport .playback-buttons{grid-column:2;grid-row:2;justify-self:center}
.transport .speed-label{grid-column:3;grid-row:2}
.table-expanded .transport{grid-template-columns:auto minmax(30px,1fr) auto auto}
.table-expanded .transport .round-jump{grid-column:1;grid-row:1}
.table-expanded .transport #seek{grid-column:2;grid-row:1;margin:0}
.table-expanded .transport .playback-buttons{grid-column:3;grid-row:1}
.table-expanded .transport .speed-label{grid-column:4;grid-row:1}
.playback-buttons{gap:2px}
.playback-buttons button{width:32px;min-height:34px;padding:6px}
.playback-buttons .play{width:38px;height:36px;border-radius:9px}
.round-jump button{min-height:34px;min-width:0;padding:5px;font-size:10px}
.speed-label select{min-height:34px}
.stage{height:clamp(380px,calc(100dvh - 286px),900px)}
.table-expanded .stage{height:100%}
@media(max-width:1000px){.speed-label{font-size:0}}
@media(max-width:760px){.transport,.table-expanded .transport{gap:6px}.playback-buttons button{width:26px;padding:4px}.playback-buttons .play{width:32px}.speed-label select{padding:4px}.stage{height:clamp(280px,88vw,620px)}}
.stage-hint{bottom:4px}
#previous,#next{touch-action:none;user-select:none;-webkit-user-select:none;-webkit-touch-callout:none}
