@font-face {
  font-family: "Shippori Mincho";
  src: url("../fonts/shippori-mincho/ShipporiMincho-ExtraBold.ttf") format("truetype");
  font-weight: 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --wood-dark: #3a1812;
  --wood-mid: #6a3222;
  --wood-light: #8a4a30;
  --wood-deep: #4a2016;
  --line: #2a120c;
  --ink: #141018;
  --paper: #16141e;
  --sente: #1c1420;
  --gote: #1a2844;
  --select: rgba(196, 160, 86, 0.42);
  --move: rgba(48, 92, 72, 0.36);
  --capture: rgba(150, 36, 40, 0.4);
  --text-on-dark: #f6f2ea;
  --text-on-dark-muted: #d8d4cc;
  --text-on-dark-disabled: #c4c0b8;
  --text-on-light: #f6f2ea;
  --text-on-light-muted: #d5d1c9;
  --text-on-light-disabled: #c2beb6;
  --btn-disabled-bg: #3a3640;
  --btn-disabled-ink: #e8e4dc;
  --surface-light: #16141e;
  --control-light: #1c1a26;
  --control-border: #6a4e2c;
  --btn-bg: #5c1828;
  --btn-ink: #f4ead4;
  --btn-border: #c4a056;
  --btn-secondary: rgba(18, 16, 28, 0.72);
  --btn-secondary-hover: rgba(40, 18, 28, 0.88);
  --modal-secondary-bg: #2a2230;
  --modal-secondary-hover: #3a2834;
  --modal-disabled-bg: #2a262e;
  --piece-face-top: #f4ead8;
  --piece-face-bot: #dcc8a0;
  --piece-edge: #5a3a24;
  --piece-promote: #8b1524;
  --page-bg:
    radial-gradient(ellipse at 50% -10%, rgba(90, 24, 40, 0.38), transparent 42%),
    radial-gradient(ellipse at 12% 18%, rgba(28, 36, 80, 0.28), transparent 46%),
    radial-gradient(ellipse at 88% 88%, rgba(48, 16, 56, 0.22), transparent 40%),
    radial-gradient(circle at top, #12141c 0%, #08070e 72%);
  --clock-pick-on-bg: #6b1c2c;
  --clock-pick-on-ink: #f6e8c8;
  --clock-pick-on-ring: #d4b46a;
  --clock-title-bg: #2c1824;
  --board-inset: #4a2818;
  --koma-clip: polygon(50% 0%, 85% 12%, 100% 100%, 0% 100%, 15% 12%);
  --koma-w: 1;
  --koma-h: 1;
  --koma-scale-x: 0.992;
  --koma-glyph-scale: 1.40;
  --koma-glyph: calc((0.72 + 0.28 * var(--koma-h)) * var(--koma-glyph-scale));
  --koma-board-w: 98%;
  --koma-board-h: 104%;
  --koma-glyph-nudge: 5%;
  --koma-edge-inset: 1px;
  --sq-aspect: 1.08;
}

html.theme-standard {
  --ink: #2b1a0e;
  --paper: #f6ecd6;
  --text-on-dark: #2b1a0e;
  --text-on-dark-muted: #4a3218;
  --text-on-dark-disabled: #5c3d1c;
  --text-on-light: #2b1a0e;
  --text-on-light-muted: #4a3218;
  --text-on-light-disabled: #5c3d1c;
  --surface-light: #f6ecd6;
  --control-light: #fff8e8;
  --control-border: #5a3214;
  --btn-bg: #f3dcb0;
  --btn-ink: #2b1a0e;
  --btn-border: transparent;
  --btn-secondary: rgba(43, 26, 14, 0.35);
  --btn-secondary-hover: rgba(43, 26, 14, 0.55);
  --modal-secondary-bg: #efe0c0;
  --modal-secondary-hover: #e4d0a4;
  --modal-disabled-bg: #d9ccb0;
  --piece-promote: #b42318;
  --clock-pick-on-bg: #f3dcb0;
  --clock-pick-on-ink: #2b1a0e;
  --clock-pick-on-ring: #8b6230;
  --clock-title-bg: #e8d5a8;
  --btn-disabled-bg: #cbb892;
  --btn-disabled-ink: #5c3d1c;
}

html.board-color-ao {
  --wood-dark: #07101c;
  --wood-mid: #16304c;
  --wood-light: #2a4e72;
  --wood-deep: #0e2240;
  --line: #9ec4e8;
  --board-inset: #6eb0dc;
  --piece-face-top: #f3efe6;
  --piece-face-bot: #d5cbb8;
  --piece-edge: #1a2a44;
  --sente: #10141c;
  --gote: #123a62;
  --select: rgba(120, 190, 230, 0.42);
  --move: rgba(70, 160, 190, 0.4);
  --capture: rgba(180, 50, 70, 0.42);
}

html.board-color-kurenai {
  --wood-dark: #2a080c;
  --wood-mid: #5a121c;
  --wood-light: #8a2430;
  --wood-deep: #3a0c14;
  --line: #e8b8a0;
  --board-inset: #c45a58;
  --piece-face-top: #f6ead8;
  --piece-face-bot: #e0c49a;
  --piece-edge: #4a1818;
  --sente: #1a0c0c;
  --gote: #3a2048;
  --select: rgba(220, 150, 90, 0.42);
  --move: rgba(160, 70, 80, 0.38);
  --capture: rgba(80, 20, 30, 0.45);
}

html.board-color-shiro {
  --wood-dark: #c8c2b6;
  --wood-mid: #f4f0e8;
  --wood-light: #fbfaf6;
  --wood-deep: #e8e2d6;
  --line: #8a8478;
  --board-inset: #d8d2c6;
  --piece-face-top: #fffdf8;
  --piece-face-bot: #efe6d4;
  --piece-edge: #6a6458;
  --sente: #1c1814;
  --gote: #1a3050;
  --select: rgba(180, 160, 90, 0.38);
  --move: rgba(90, 140, 110, 0.32);
  --capture: rgba(180, 70, 70, 0.32);
}

html.board-color-classic {
  /* 茶：テーマ側の --wood-* を使う */
}

html.board-color-ao-light {
  --wood-dark: #1a3a58;
  --wood-mid: #4a7aa4;
  --wood-light: #7aa8cc;
  --wood-deep: #2e5a82;
  --line: #16344c;
  --board-inset: #d8e8f4;
  --piece-face-top: #fffaf2;
  --piece-face-bot: #ead9b8;
  --piece-edge: #2a3a52;
  --sente: #10141c;
  --gote: #0c3060;
  --select: rgba(80, 150, 200, 0.38);
  --move: rgba(50, 130, 160, 0.36);
  --capture: rgba(190, 60, 70, 0.38);
}

html.board-color-kurenai-light {
  --wood-dark: #6a1820;
  --wood-mid: #b84850;
  --wood-light: #d87878;
  --wood-deep: #8a2830;
  --line: #4a1014;
  --board-inset: #f4d0c8;
  --piece-face-top: #fff6ea;
  --piece-face-bot: #edd2a8;
  --piece-edge: #5a2020;
  --sente: #1a0c0c;
  --gote: #2a1840;
  --select: rgba(220, 140, 90, 0.38);
  --move: rgba(170, 70, 80, 0.32);
  --capture: rgba(90, 24, 32, 0.4);
}

html.board-color-shiro-light {
  --wood-dark: #b8b4aa;
  --wood-mid: #fbfaf7;
  --wood-light: #ffffff;
  --wood-deep: #eeece6;
  --line: #6a665c;
  --board-inset: #ffffff;
  --piece-face-top: #ffffff;
  --piece-face-bot: #f0e6d2;
  --piece-edge: #5a564c;
  --sente: #141210;
  --gote: #142848;
  --select: rgba(190, 170, 80, 0.34);
  --move: rgba(80, 140, 110, 0.3);
  --capture: rgba(190, 70, 70, 0.3);
}

html.board-color-classic-light {
  --wood-dark: #7a4a28;
  --wood-mid: #d4a06a;
  --wood-light: #f0d0a0;
  --wood-deep: #c88848;
  --line: #5a3214;
  --board-inset: #f8e4c4;
  --piece-face-top: #fff8ea;
  --piece-face-bot: #ead4a4;
  --piece-edge: #8b6230;
  --sente: #2b1a0e;
  --gote: #1e3a6b;
  --select: rgba(255, 214, 64, 0.45);
  --move: rgba(70, 160, 80, 0.32);
  --capture: rgba(210, 70, 50, 0.36);
}

html.theme-bg-cathedral {
  --page-bg: #07060c;
  --btn-bg: #4a2030;
  --clock-title-bg: #24141c;
}
html.theme-bg-aomoon {
  --page-bg: #050814;
  --btn-bg: #183868;
  --clock-title-bg: #142038;
}
html.theme-bg-redmoon {
  --page-bg: #0c0608;
  --btn-bg: #6a1424;
  --clock-title-bg: #2c1018;
}
html.theme-bg-library {
  --page-bg: #100c08;
  --btn-bg: #5a3014;
  --clock-title-bg: #24180c;
}
html.theme-bg-magic {
  --page-bg: #08060a;
  --btn-bg: #4a3810;
  --clock-title-bg: #20180c;
}
html.theme-bg-shrine {
  --page-bg: #080910;
  --btn-bg: #3a1c28;
  --clock-title-bg: #18141c;
}
html.theme-bg-castle {
  --page-bg: #0c1016;
  --btn-bg: #2a3848;
  --clock-title-bg: #182028;
}
html.theme-bg-abyss {
  --page-bg: #04040a;
  --btn-bg: #241848;
  --clock-title-bg: #141028;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  color: var(--text-on-dark);
  background: var(--page-bg);
  position: relative;
}

html.theme-dark body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.22;
  background:
    repeating-linear-gradient(
      90deg,
      transparent 0 46px,
      rgba(196, 160, 86, 0.035) 46px 47px
    ),
    radial-gradient(ellipse at 50% 120%, rgba(80, 16, 32, 0.18), transparent 55%);
}

html.theme-bg-cathedral body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(8, 6, 12, 0.58), rgba(8, 6, 14, 0.78)),
    radial-gradient(ellipse at 50% -8%, rgba(240, 220, 150, 0.38), transparent 36%),
    repeating-linear-gradient(90deg, rgba(40, 28, 22, 0.55) 0 28px, rgba(18, 14, 18, 0.4) 28px 52px),
    radial-gradient(circle at 50% 120%, #1a1014 0%, #07060c 70%);
}
html.theme-bg-aomoon body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(4, 8, 18, 0.5), rgba(4, 6, 14, 0.78)),
    radial-gradient(circle at 78% 12%, rgba(210, 230, 255, 0.55) 0 7%, rgba(120, 170, 230, 0.18) 14%, transparent 28%),
    radial-gradient(ellipse at 20% 80%, rgba(30, 60, 130, 0.28), transparent 42%),
    linear-gradient(180deg, #071018 0%, #04060e 100%);
}
html.theme-bg-redmoon body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(12, 4, 8, 0.5), rgba(10, 4, 8, 0.8)),
    radial-gradient(circle at 76% 10%, rgba(255, 90, 70, 0.5) 0 6%, rgba(160, 30, 24, 0.22) 16%, transparent 30%),
    radial-gradient(ellipse at 30% 90%, rgba(80, 10, 16, 0.35), transparent 45%),
    linear-gradient(180deg, #14080c 0%, #080406 100%);
}
html.theme-bg-library body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(10, 8, 6, 0.55), rgba(10, 8, 6, 0.78)),
    radial-gradient(ellipse at 50% 0%, rgba(220, 160, 70, 0.2), transparent 40%),
    repeating-linear-gradient(90deg, rgba(90, 48, 20, 0.35) 0 10px, rgba(30, 18, 10, 0.5) 10px 18px, rgba(70, 36, 16, 0.28) 18px 26px),
    linear-gradient(180deg, #1a120c 0%, #0c0806 100%);
}
html.theme-bg-magic body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(8, 6, 10, 0.62), rgba(8, 6, 10, 0.8)),
    repeating-conic-gradient(from 0deg at 50% 55%, rgba(212, 180, 90, 0.14) 0 6deg, transparent 6deg 18deg),
    radial-gradient(circle at 50% 55%, transparent 18%, rgba(212, 180, 90, 0.16) 19%, transparent 21%, rgba(212, 180, 90, 0.12) 34%, transparent 36%),
    linear-gradient(180deg, #100c14 0%, #08060a 100%);
}
html.theme-bg-shrine body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(6, 8, 14, 0.55), rgba(6, 8, 14, 0.8)),
    radial-gradient(ellipse at 50% 100%, rgba(180, 40, 40, 0.16), transparent 40%),
    linear-gradient(90deg, transparent 42%, rgba(160, 40, 40, 0.22) 42% 43%, transparent 43% 57%, rgba(160, 40, 40, 0.22) 57% 58%, transparent 58%),
    radial-gradient(circle at 50% 18%, rgba(220, 230, 255, 0.12), transparent 30%),
    linear-gradient(180deg, #0c1018 0%, #06070c 100%);
}
html.theme-bg-castle body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(8, 12, 18, 0.52), rgba(8, 12, 18, 0.8)),
    radial-gradient(circle at 70% 8%, rgba(230, 240, 255, 0.28) 0 5%, transparent 18%),
    repeating-radial-gradient(circle at 20% 10%, rgba(255, 255, 255, 0.12) 0 1px, transparent 1px 46px),
    linear-gradient(180deg, #121820 0%, #080a10 100%);
}
html.theme-bg-abyss body::before {
  opacity: 1;
  background:
    linear-gradient(180deg, rgba(4, 4, 12, 0.5), rgba(4, 4, 12, 0.82)),
    radial-gradient(circle at 18% 22%, rgba(180, 200, 255, 0.18) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 18%, rgba(220, 180, 255, 0.16) 0 1px, transparent 2px),
    radial-gradient(ellipse at 50% 80%, rgba(60, 40, 140, 0.28), transparent 50%),
    linear-gradient(180deg, #080814 0%, #04040a 100%);
}

html.has-photo-bg body::before {
  display: none;
}

.app-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: #08070e;
}

.app-bg-layer {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  transition: opacity 0.45s ease;
}

.app-bg-layer.is-shown {
  opacity: 1;
}

:root {
  --board-fit: min(92vw, calc(68vh / var(--sq-aspect)), 640px);
  --board-height: calc(var(--board-fit) * var(--sq-aspect));
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1280px;
  margin: 0 auto;
  padding: 8px 270px 16px 120px;
}

.header {
  display: none;
}

.header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 4vw, 2.2rem);
  letter-spacing: 0.12em;
  color: var(--text-on-dark);
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.72);
}

.header h1 span {
  font-size: 1rem;
  letter-spacing: 0.2em;
  color: var(--text-on-dark-muted);
  text-shadow: 0 1px 8px rgba(0, 0, 0, 0.7);
}

.subtitle {
  margin: 8px 0 0;
  color: var(--text-on-dark-muted);
  font-size: 0.95rem;
}

.table {
  position: relative;
  width: fit-content;
  margin: 0 auto;
}

.gote-area,
.sente-area {
  position: absolute;
  z-index: 2;
  top: 28px;
  width: 96px;
  height: var(--board-height);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.gote-area {
  left: 0;
  transform: translateX(-108%);
}

.sente-area {
  right: 0;
  bottom: auto;
  width: 96px;
  transform: translateX(calc(108% + 16px));
}

.app:not(.editing) {
  padding-right: 270px;
  padding-left: 120px;
}

.app.view-swapped:not(.editing) {
  padding-right: 270px;
  padding-left: 120px;
}

.app.view-swapped .gote-area {
  top: 28px;
  left: auto;
  bottom: auto;
  right: 0;
  width: 96px;
  transform: translateX(calc(108% + 16px));
}

.app.view-swapped .sente-area {
  top: 28px;
  right: auto;
  bottom: auto;
  left: 0;
  width: 96px;
  transform: translateX(-108%);
}

.app.editing {
  padding-left: 156px;
  padding-right: 156px;
}

.app.editing .gote-area,
.app.editing .sente-area,
.app.editing .editor-bench {
  width: 128px;
  overflow: hidden;
  box-sizing: border-box;
}

.app.editing .gote-area,
.app.editing .sente-area {
  padding: 6px 6px 4px;
}

.app.editing .turn-hint {
  display: none;
}

.app.editing .gote-area {
  top: 28px;
  height: calc(var(--board-height) * 0.56);
}

.app.editing .sente-area {
  top: auto;
  bottom: 0;
  width: 128px;
  height: calc(var(--board-height) * 0.56);
  flex-direction: column;
}

.app.editing .sente-main {
  width: 100%;
  flex: 1 1 auto;
}

.app.editing.view-swapped .sente-area {
  top: 28px;
  bottom: auto;
  left: 0;
  right: auto;
  transform: translateX(-108%);
}

.app.editing.view-swapped .gote-area {
  top: auto;
  bottom: 0;
  left: auto;
  right: 0;
  transform: translateX(calc(108% + 16px));
}

.app.editing .editor-bench {
  top: auto;
  bottom: 0;
  height: calc(var(--board-height) * 0.42);
  left: 0;
  transform: translateX(-108%);
}

.app.editing.view-swapped .editor-bench {
  left: 0;
  right: auto;
  transform: translateX(-108%);
}

.app.editing .subtitle {
  display: none;
}

.app.editing .header {
  margin-bottom: 4px;
}

.app.editing .hand {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 2px;
  overflow: hidden;
  width: 100%;
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
  justify-content: space-evenly;
  align-items: stretch;
  align-content: stretch;
}

.app.editing .gote-area .hand,
.app.editing .sente-area .hand {
  flex: 1 1 auto;
  margin: 0;
  align-items: stretch;
  align-content: stretch;
}

.app.editing .hand-edit {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 3px;
  margin: 0;
  padding: 0;
  max-width: 100%;
  width: 100%;
  box-sizing: border-box;
  flex: 0 0 auto;
}

.app.editing .hand-edit .hand-piece {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 2px;
  width: auto;
  min-width: 0;
  height: 30px;
  padding: 0 2px;
  flex: 0 1 auto;
}

.app.editing .hand-edit .piece {
  width: calc(22px * var(--koma-w) * var(--koma-scale-x));
  height: calc(26px * var(--koma-h));
  font-size: calc(0.78rem * var(--koma-glyph));
  flex: 0 0 auto;
}

.app.editing .hand-edit-btn {
  width: 22px;
  min-width: 22px;
  height: 24px;
  font-size: 0.78rem;
  padding: 0;
  flex: 0 0 22px;
}

.app.editing .hand-edit .hand-count {
  position: static;
  right: auto;
  bottom: auto;
  min-width: 1.05em;
  padding: 0 3px;
  font-size: 0.72rem;
  line-height: 1.2;
  flex: 0 0 auto;
}

.board-wrap {
  position: relative;
  z-index: 1;
  overflow: visible;
}

.player-area {
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(246, 236, 214, 0.08);
  border: 1px solid rgba(243, 220, 176, 0.2);
}

.player-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  min-height: 0;
  flex: 1 1 auto;
  align-content: flex-start;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

.player-area.active {
  box-shadow: 0 0 0 2px #f3dcb0, 0 8px 24px rgba(0, 0, 0, 0.35);
}

.player-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
}

.player-area .turn-hint {
  margin: 0;
  font-size: 0.8rem;
  text-align: center;
}

.hand {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin: 8px 0 0;
  min-height: 0;
  flex: 1 1 auto;
  align-content: flex-start;
  align-items: flex-start;
  justify-content: center;
  overflow-x: hidden;
  overflow-y: auto;
}

.sente-area {
  justify-content: flex-end;
  flex-direction: column;
  align-items: stretch;
  width: 96px;
}

.sente-main {
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  width: 96px;
  flex: 0 0 96px;
  min-width: 0;
  min-height: 0;
}

.sente-main .hand {
  flex: 0 1 auto;
  width: 100%;
  margin: auto 0 8px;
  order: 1;
}

.sente-main .player-head {
  order: 2;
}

.sente-main .board-side-tools {
  order: 0;
}

.gote-area {
  justify-content: flex-start;
}

.sente-area .hand {
  flex: 0 1 auto;
  margin: auto 0 8px;
  align-content: flex-end;
  align-items: flex-end;
}

.gote-area .hand {
  flex: 0 1 auto;
  margin: 8px 0 auto;
  align-content: flex-start;
  align-items: flex-start;
}

.hand-piece {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 54px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
}

.hand-piece.selected {
  background: var(--select);
  border-color: #f3dcb0;
}

.hand-piece .piece {
  width: calc(100% * var(--koma-w) * var(--koma-scale-x));
  height: calc(100% * var(--koma-h));
  font-size: calc(1.15rem * var(--koma-glyph));
}

.hand-count {
  position: absolute;
  right: -6px;
  bottom: -4px;
  background: #f3dcb0;
  color: var(--ink);
  border-radius: 999px;
  font-size: 0.75rem;
  min-width: 18px;
  padding: 1px 5px;
}

.hand-empty {
  margin: 0;
  color: #f6f2ea;
  font-size: 0.9rem;
  font-weight: 700;
}

.control-buttons {
  display: flex;
  flex-direction: column;
  flex-wrap: nowrap;
  gap: 6px;
  justify-content: flex-start;
  align-items: stretch;
  width: 100%;
}

.control-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  width: 100%;
}

.control-row-end,
.control-row-tools,
.control-row-start {
  justify-content: flex-start;
}

.control-row-end button,
.control-row-tools button,
.control-row-start button {
  padding: 8px 12px;
  font-size: 0.9rem;
  white-space: nowrap;
}

#resignButton,
.resign-btn {
  order: 99;
  margin-left: auto;
  background: rgba(72, 22, 32, 0.78);
  color: #f3e0d4;
  border-color: #b07070;
}

#resignButton:hover,
.resign-btn:hover {
  background: rgba(96, 28, 40, 0.9);
  border-color: #c48888;
}

.control-row-seats {
  flex-wrap: wrap;
}

.opening-title {
  margin: 0;
  max-width: 100%;
  font-size: 1rem;
  font-weight: 800;
}

.kifu-side-opening {
  font-size: 0.74rem;
  white-space: normal;
  overflow: visible;
  text-overflow: unset;
}

.ui-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: #141014;
  color: #f6f2ea;
  font-size: 0.85rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  line-height: 1.2;
  white-space: nowrap;
}

.hand-empty.ui-pill {
  margin: 0 auto;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
}

.app.editing .control-buttons .play-only {
  display: none;
}

.app.editing .status {
  display: none;
}

.editor-quick-bar {
  display: none;
}

.app.editing .editor-quick-bar {
  display: inline-flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  width: auto;
  position: static;
  transform: none;
}

.app.editing .editor-quick-bar button {
  white-space: nowrap;
}

.editor-rclick-toggle {
  display: none;
}

.app.editing .editor-rclick-toggle {
  display: none;
}

@media (hover: none), (pointer: coarse), (max-width: 720px) {
  .board-side-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 4px;
    width: auto;
    margin: 0;
  }

  .history-btns {
    display: flex;
    gap: 4px;
  }

  .history-btn {
    width: 32px;
    min-width: 32px;
    height: 30px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
  }

  .app.editing .editor-rclick-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.62rem;
    padding: 3px 6px;
    line-height: 1.1;
    min-height: 30px;
    width: auto;
    max-width: max-content;
    flex: 0 0 auto;
  }
}

.app.editing .editor-quick-bar button.editor-rclick-toggle {
  width: auto;
  max-width: max-content;
  min-width: 0;
  flex: 0 0 auto;
}

.app.editing .editor-rclick-toggle.is-on,
.app.editing .editor-rclick-toggle[aria-pressed="true"] {
  background: #1e3a8a;
  color: #fff8e8;
  box-shadow: inset 0 0 0 2px #fde68a;
  font-weight: 800;
}

.editor-turn-status {
  color: var(--text-on-dark);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.position-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--text-on-dark);
  font-size: 0.95rem;
  font-weight: 700;
}

.position-label select,
.position-label .seat-toggle {
  font-family: inherit;
  border-radius: 10px;
  padding: 8px 12px;
  background: #fff8e8;
  color: #2b1a0e;
  border: 1px solid #fff4c2;
  cursor: pointer;
  font-weight: 700;
  color-scheme: light;
  min-width: 5.5em;
}

.position-label select option {
  background: #fff8e8;
  color: #2b1a0e;
}

button.active-toggle {
  background: var(--clock-pick-on-bg);
  color: var(--clock-pick-on-ink);
  box-shadow: inset 0 0 0 1px var(--clock-pick-on-ring);
}

.side-panel {
  min-height: 180px;
  padding: 16px 12px;
  border-radius: 14px;
  background: rgba(246, 236, 214, 0.08);
  border: 1px solid rgba(243, 220, 176, 0.2);
  text-align: center;
}

.player-badge {
  display: inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  font-weight: bold;
  letter-spacing: 0.12em;
  color: #fff;
  font-size: 0.85rem;
}

.player-badge.sente {
  background: var(--sente);
}

.player-badge.gote {
  background: var(--gote);
}

.turn-hint {
  margin: 16px 0 0;
  color: var(--text-on-dark);
  font-size: 0.95rem;
  font-weight: 700;
}

.photo-outline {
  color: #f6f2ea;
  -webkit-text-stroke: 0.55px rgba(16, 12, 14, 0.92);
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #141014,
    1px -1px 0 #141014,
    -1px 1px 0 #141014,
    1px 1px 0 #141014,
    0 0 3px #141014;
}

.photo-outline-dark {
  color: #111111;
  -webkit-text-stroke: 0.5px #f4ead6;
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #f7efe0,
    1px -1px 0 #f7efe0,
    -1px 1px 0 #f7efe0,
    1px 1px 0 #f7efe0;
}

.catalog-mini .mini-turn,
p.mini-turn {
  color: #111111 !important;
  -webkit-text-stroke: 0;
  text-shadow: none;
  paint-order: normal;
}

.side-panel.active {
  box-shadow: 0 0 0 2px #f3dcb0, 0 8px 24px rgba(0, 0, 0, 0.35);
}

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
}

.board-chrome {
  display: grid;
  grid-template-columns: var(--board-fit) 1.35em;
  grid-template-rows: auto var(--board-height);
  align-items: stretch;
  justify-content: center;
}

.file-labels,
.rank-labels {
  display: grid;
  color: var(--text-on-dark);
  font-size: 0.9rem;
  font-weight: 700;
}

.file-labels {
  grid-column: 1;
  grid-row: 1;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  margin-bottom: 6px;
  text-align: center;
}

.rank-labels {
  grid-column: 2;
  grid-row: 2;
  grid-template-rows: repeat(9, 1fr);
  margin-left: 6px;
  place-items: center;
}

.board-stack {
  grid-column: 1;
  grid-row: 2;
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  isolation: isolate;
}

.onijin-fx {
  position: absolute;
  inset: 0;
  z-index: 12;
  pointer-events: none;
  overflow: hidden;
  background: transparent;
  transform: none;
  mix-blend-mode: normal;
  isolation: isolate;
}

.onijin-button {
  position: absolute;
  top: -8px;
  right: -6.4rem;
  z-index: 8;
  min-width: 6.2rem;
  padding: 7px 12px;
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.2;
  white-space: nowrap;
  color: #fff8e8;
  background: linear-gradient(180deg, #c4451a, #7a1c10);
  border: 2px solid #f3dcb0;
  box-shadow: 0 3px 0 #3a0d08, 0 6px 12px rgba(0, 0, 0, 0.35);
}

.onijin-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #3a0d08;
}

.app.editing .onijin-button {
  display: none;
}

.promote-choice {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}

.promote-choice.hidden {
  display: none;
}

.promote-choice button {
  position: absolute;
  pointer-events: auto;
  margin: 0;
  min-width: 52px;
  min-height: 36px;
  padding: 5px 8px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 800;
  line-height: 1.1;
}

#promoteYes {
  box-shadow: 0 0 0 2px #fff4c2, 0 4px 10px rgba(0, 0, 0, 0.35);
}

#promoteNo {
  background: #efe0c4;
  color: #3a2410;
}

.onijin-fx.hidden {
  display: none;
}

.onijin-frame-wrap {
  position: absolute;
  left: var(--onijin-x, 50%);
  top: var(--onijin-y, 50%);
  width: 0;
  height: 0;
  pointer-events: none;
}

.onijin-slash {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--onijin-w, min(480px, 78vw));
  height: auto;
  max-width: none;
  border: 0;
  outline: none;
  box-shadow: none;
  background: transparent;
  mix-blend-mode: normal;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  transform-origin: 80.4% 81.2%;
  transform: translate(-80.4%, -81.2%) rotate(var(--onijin-rot, 0deg));
  opacity: 1;
  clip-path: inset(0 66.67% 0 0);
  animation:
    onijin-slash-draw 0.18s linear forwards,
    onijin-slash-fade 0.06s linear 0.18s forwards;
}

@keyframes onijin-slash-draw {
  0%,
  32.9% {
    clip-path: inset(0 66.67% 0 0);
  }
  33%,
  65.9% {
    clip-path: inset(0 33.33% 0 0);
  }
  66%,
  100% {
    clip-path: inset(0 0 0 0);
  }
}

@keyframes onijin-slash-fade {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.onijin-frame-wrap.is-mamori-blocked {
  z-index: 8;
}

.onijin-fx.is-mamori-view .onijin-frame-wrap.is-mamori-blocked {
  z-index: 2;
}

.onijin-fx.is-mamori-view .mamori-guard-wrap {
  z-index: 8;
}

.onijin-fx.is-mamori-view .mamori-shatter-wrap {
  z-index: 6;
}

.onijin-fx.is-mamori-view .mamori-ring {
  z-index: 7;
}

.onijin-fx.is-mamori-view .mamori-flash,
.onijin-fx.is-mamori-view .mamori-sparks {
  z-index: 9;
}

.onijin-slash.is-mamori-blocked {
  animation:
    onijin-slash-draw 0.18s linear forwards,
    mamori-slash-reject 0.1s ease-in 0.3s forwards;
}

@keyframes mamori-slash-reject {
  0% {
    opacity: 1;
    filter: brightness(1.15);
  }
  100% {
    opacity: 0;
    filter: brightness(2.4);
  }
}

.mamori-gather,
.mamori-ring,
.mamori-flash,
.mamori-sparks {
  position: absolute;
  left: var(--mamori-x, 50%);
  top: var(--mamori-y, 50%);
  pointer-events: none;
  user-select: none;
}

.mamori-gather {
  z-index: 1;
  width: min(42%, 220px);
  height: min(42%, 220px);
  border-radius: 50%;
  background: radial-gradient(circle, rgba(236, 250, 255, 0.92) 0%, rgba(140, 206, 255, 0.42) 34%, transparent 72%);
  opacity: 0;
  transform: translate(-50%, -50%) scale(1.55);
  animation: mamori-gather 0.1s ease-in 0.14s both;
}

@keyframes mamori-gather {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.55);
  }
  62% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(0.38);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.1);
  }
}

.mamori-ring {
  z-index: 3;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid rgba(196, 236, 255, 0.92);
  box-shadow: 0 0 16px rgba(150, 214, 255, 0.7);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35);
  animation: mamori-ring 0.34s ease-out 0.2s both;
}

@keyframes mamori-ring {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  16% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.4);
  }
}

.mamori-flash {
  z-index: 4;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0%, rgba(210, 240, 255, 0.82) 26%, transparent 70%);
  mix-blend-mode: screen;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  animation: mamori-flash 0.12s ease-out 0.3s both;
}

@keyframes mamori-flash {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  28% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.35);
  }
}

.mamori-sparks {
  z-index: 4;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #f4fbff;
  box-shadow:
    16px -14px 0 0 #d4efff,
    -20px 10px 0 0 #9fd2ff,
    10px 22px 0 0 #fff,
    -12px -22px 0 0 #c4e6ff,
    26px 4px 0 0 #e8f7ff,
    -4px 18px 0 0 #b8dcff,
    8px -26px 0 0 #fff;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.4);
  animation: mamori-sparks 0.24s ease-out 0.3s both;
}

@keyframes mamori-sparks {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.85);
  }
}

.mamori-guard-wrap {
  position: absolute;
  left: var(--mamori-x, 50%);
  top: var(--mamori-y, 50%);
  width: 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}

.mamori-guard,
.mamori-guard-fallback {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  animation: mamori-guard-burst 0.45s ease-out 0.2s both;
}

.mamori-guard {
  width: var(--mamori-w, 180px);
  height: auto;
  max-height: none;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: 0;
  outline: none;
  box-shadow: none;
  transform: translate(-50%, -50%);
}

.mamori-guard-fallback {
  display: none;
  width: var(--mamori-w, 180px);
  aspect-ratio: 3 / 4;
  clip-path: polygon(18% 0%, 82% 0%, 97% 22%, 50% 100%, 3% 22%);
  background:
    radial-gradient(ellipse at 50% 28%, rgba(255, 255, 255, 0.92), rgba(186, 224, 255, 0.62) 42%, rgba(72, 148, 230, 0.18) 76%, transparent 100%);
  box-shadow: 0 0 22px rgba(160, 214, 255, 0.55);
  transform: translate(-50%, -50%);
}

.mamori-guard-wrap.is-missing .mamori-guard-fallback {
  display: block;
}

.mamori-guard-wrap.has-image .mamori-guard-fallback {
  display: none;
}

.mamori-guard-wrap.has-image .mamori-guard {
  display: block;
}

@keyframes mamori-guard-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08);
  }
  10% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.16);
  }
  22% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  44% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.03);
  }
}

.mamori-guard-wrap.is-failed .mamori-guard,
.mamori-guard-wrap.is-failed .mamori-guard-fallback {
  animation:
    mamori-guard-fail-in 0.1s ease-out 0.2s both,
    mamori-guard-break-out 0.08s linear 0.3s forwards;
}

@keyframes mamori-guard-fail-in {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08);
  }
  35% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.12);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
}

@keyframes mamori-guard-break-out {
  0% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.04);
  }
}

.mamori-shatter-wrap {
  position: absolute;
  left: var(--mamori-x, 50%);
  top: var(--mamori-y, 50%);
  width: 0;
  height: 0;
  z-index: 3;
  pointer-events: none;
}

.mamori-shatter {
  position: absolute;
  left: 0;
  top: 0;
  width: var(--mamori-shatter-w, var(--mamori-w, 180px));
  height: auto;
  max-width: none;
  object-fit: contain;
  object-position: center;
  background: transparent;
  border: 0;
  outline: none;
  box-shadow: none;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
  opacity: 0;
  transform: translate(-50%, -50%);
  animation: mamori-shatter-burst 0.25s ease-out 0.3s both;
}

@keyframes mamori-shatter-burst {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
  12% {
    opacity: 0.95;
    transform: translate(-50%, -50%) scale(1);
  }
  36% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.22);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.48);
  }
}

.seat-toggle {
  min-width: 5.4rem;
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: 800;
}

.seat-toggle.is-ai {
  background: #3a1c28;
  color: #f6e8c8;
}

.board {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  overflow: hidden;
  background: linear-gradient(160deg, var(--wood-light), var(--wood-mid) 55%, var(--wood-deep));
  border: 10px solid var(--wood-dark);
  box-shadow:
    inset 0 0 0 2px var(--board-inset),
    0 16px 40px rgba(0, 0, 0, 0.45);
}

html.board-style-design .board {
  background-color: var(--wood-mid);
  background-image: var(--board-design-image);
  background-size: 100% 100%;
  background-position: center;
  background-repeat: no-repeat;
}

html.board-style-design .mini-board {
  background-color: var(--koma-mini-sq);
  background-image: none;
}

.board::before {
  content: none;
}

html.board-show-bg .board::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background-image: var(--app-bg-image);
  background-size: cover;
  background-position: center;
  background-attachment: fixed;
  background-repeat: no-repeat;
  opacity: var(--board-bg-see, 0.14);
  mix-blend-mode: normal;
}

html.board-style-design.board-show-bg .board::before {
  opacity: var(--board-bg-see, 0.12);
  mix-blend-mode: normal;
}

.board::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: var(--board-grain, 0);
  background:
    repeating-linear-gradient(
      90deg,
      rgba(20, 16, 12, 0.18) 0 1px,
      transparent 1px 11px
    ),
    linear-gradient(180deg, rgba(255, 255, 255, var(--board-sheen, 0)), transparent 42%);
}

html.board-style-design .board::after {
  opacity: 0.08;
}

.square {
  position: relative;
  z-index: 1;
  border: var(--board-line-width, 1px) solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 0;
  margin: 0;
  background: transparent;
  border-radius: 0;
  appearance: none;
  container-type: size;
}

.board .piece,
.board .piece.gote,
.app.view-swapped .board .piece.sente,
.app.view-swapped .board .piece.gote {
  align-self: center;
}

.square:focus-visible {
  outline: 2px solid #fff4c2;
  outline-offset: -2px;
  z-index: 1;
}

.square.selected {
  background: transparent;
}

.square.last-move {
  background: rgba(46, 128, 230, 0.3);
  box-shadow: inset 0 0 11px rgba(90, 180, 255, 0.42);
}

.square.editor-selected {
  background: rgba(255, 214, 90, 0.5);
  box-shadow: inset 0 0 0 3px #ffe08a;
}

.square.editor-selected.selected {
  background: rgba(255, 196, 48, 0.65);
}

.square.editor-drop-preview {
  background: rgba(90, 180, 255, 0.35);
  box-shadow: inset 0 0 0 3px #8ec8ff;
}

.app.editing .board {
  touch-action: none;
  user-select: none;
}

.editor-marquee {
  position: absolute;
  border: 2px dashed #fff4c2;
  background: rgba(255, 244, 194, 0.18);
  pointer-events: none;
  z-index: 4;
}

.editor-marquee.hidden {
  display: none;
}

.editor-bench {
  position: absolute;
  z-index: 2;
  top: 28px;
  left: 0;
  width: 96px;
  height: var(--board-height);
  transform: translateX(-108%);
  margin: 0;
  padding: 8px 6px;
  border-radius: 14px;
  background: rgba(246, 236, 214, 0.1);
  border: 1px solid rgba(255, 244, 194, 0.4);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.editor-bench.drop-target {
  box-shadow: inset 0 0 0 2px #8ec8ff;
  background: rgba(90, 180, 255, 0.18);
}

.editor-bench-head {
  color: var(--text-on-dark);
  font-weight: 800;
  text-align: center;
  margin-bottom: 6px;
  font-size: 0.82rem;
}

.editor-bench-pieces {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  align-content: end;
  min-height: 0;
  flex: 1 1 auto;
  overflow: hidden;
}

.editor-bench-piece {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0;
  width: 100%;
  min-height: 42px;
  height: auto;
  padding: 2px 1px 10px;
  background: #fff8e8;
  color: #2b1a0e;
  border: 1px solid #8b6230;
  border-radius: 8px;
  position: relative;
}

.editor-bench-piece .piece {
  width: calc(22px * var(--koma-w) * var(--koma-scale-x));
  height: calc(26px * var(--koma-h));
  font-size: calc(0.72rem * var(--koma-glyph));
}

.editor-bench-piece .hand-count {
  position: absolute;
  right: 1px;
  bottom: 1px;
  background: #5a3214;
  color: #fff4c2;
  font-weight: 800;
  font-size: 0.68rem;
  min-width: 14px;
  padding: 0 3px;
}

.editor-bench-piece.editor-selected {
  background: #5a3214;
  border-color: #fff4c2;
}

.editor-bench-piece.editor-selected .hand-count {
  background: #fff4c2;
  color: #2b1a0e;
}

.editor-bench .hand-empty {
  color: var(--text-on-dark);
  font-weight: 700;
  text-align: center;
}

.editor-drag-ghost,
.editor-drag-ghost.hidden {
  display: none !important;
}

.editor-carry {
  --koma-w: 1;
  --koma-h: 1;
  --koma-glyph: calc((0.72 + 0.28 * var(--koma-h)) * var(--koma-glyph-scale));
  position: fixed;
  z-index: 30000;
  width: calc(36px * var(--koma-w) * var(--koma-scale-x));
  height: calc(42px * var(--koma-h));
  margin: 0;
  padding: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  clip-path: var(--koma-clip);
  -webkit-clip-path: var(--koma-clip);
  background: var(--piece-edge);
  border: none;
  font-size: calc(15px * var(--koma-glyph));
  font-weight: 800;
  font-family: "Shippori Mincho", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  box-shadow: none;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.35));
  user-select: none;
}

.editor-carry,
.editor-carry.hidden {
  display: none !important;
}

.editor-carry.gote {
  transform: rotate(180deg);
  color: var(--gote);
}

.editor-carry.sente {
  color: var(--sente);
}

.editor-carry.promoted {
  color: #b42318;
}

.square,
.piece {
  -webkit-user-drag: none;
  user-select: none;
}

.player-area.drop-target .hand,
.hand.drop-target {
  box-shadow: inset 0 0 0 2px #8ec8ff;
}

.editor-selection-menu {
  position: absolute;
  top: 0;
  left: 0;
  right: auto;
  bottom: auto;
  z-index: 12;
  display: flex;
  flex-direction: row;
  align-items: stretch;
  margin: 0;
  padding: 2px 3px;
  border-radius: 8px;
  background: rgba(20, 16, 12, 0.92);
  border: 1px solid rgba(255, 224, 138, 0.55);
  width: max-content;
  max-width: 100%;
  height: auto;
  box-sizing: border-box;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
  pointer-events: auto;
}

.editor-selection-menu .editor-row {
  display: flex;
  flex-wrap: nowrap;
  align-items: stretch;
  gap: 2px;
  margin: 0;
  width: 100%;
  pointer-events: auto;
}

.editor-selection-menu button {
  flex: 1 1 auto;
  padding: 9px 4px;
  min-width: 0;
  min-height: 40px;
  font-size: clamp(0.58rem, 1.7vw, 0.78rem);
  line-height: 1.1;
  white-space: nowrap;
  pointer-events: auto;
}

@media (hover: none), (pointer: coarse) {
  .editor-selection-menu button {
    min-height: 40px;
    padding: 9px 4px;
  }
}

.editor-context-menu {
  position: fixed;
  z-index: 12000;
  min-width: 160px;
  padding: 6px;
  border-radius: 10px;
  background: #2a2218;
  border: 1px solid #f3dcb0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.editor-context-menu.hidden {
  display: none;
}

.editor-context-menu button {
  width: 100%;
  min-width: 0;
  font-size: 0.9rem;
}

.square.movable::after {
  content: "";
  width: 18%;
  height: 18%;
  border-radius: 50%;
  background: var(--move);
}

.square.capturable {
  background: var(--capture);
}

.piece {
  --koma-w: 1;
  --koma-h: 1;
  --koma-glyph: calc((0.72 + 0.28 * var(--koma-h)) * var(--koma-glyph-scale));
  position: relative;
  isolation: isolate;
  width: calc(var(--koma-board-w) * var(--koma-w) * var(--koma-scale-x));
  height: calc(var(--koma-board-h) * var(--koma-h) * 100cqw / 100%);
  clip-path: var(--koma-clip);
  -webkit-clip-path: var(--koma-clip);
  background: var(--piece-edge);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: calc(clamp(1rem, 3.4vw, 1.7rem) * var(--koma-glyph));
  font-weight: 800;
  font-family: "Shippori Mincho", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  line-height: 1;
  box-shadow: none;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.28));
  user-select: none;
}

.piece::before,
.editor-carry::before {
  content: "";
  position: absolute;
  inset: var(--koma-edge-inset);
  clip-path: var(--koma-clip);
  -webkit-clip-path: var(--koma-clip);
  background: linear-gradient(180deg, var(--piece-face-top), var(--piece-face-bot));
  z-index: 0;
  pointer-events: none;
}

.piece-glyph {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: inherit;
  background: transparent;
  pointer-events: none;
  line-height: 1;
  transform: translateY(var(--koma-glyph-nudge));
}

.piece.piece-picked {
  background: #143e7a;
  box-shadow: none;
  filter: drop-shadow(0 0 6px rgba(70, 160, 255, 0.55));
}

.piece.piece-picked::before {
  background: linear-gradient(180deg, #9ad6ff 0%, #2f7fe0 55%, #1859b0 100%);
}

.piece.piece-picked .piece-glyph {
  color: inherit;
}

.piece-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 0.88;
  font-weight: 800;
  letter-spacing: 0;
}

.piece-stack-top,
.piece-stack-bottom {
  font-size: 0.58em;
  font-weight: 800;
}

.piece.gote {
  transform: rotate(180deg);
  color: var(--gote);
}

.piece.sente {
  transform: none;
  color: var(--sente);
}

.piece.koma-king,
.editor-carry.koma-king {
  --koma-w: 1;
  --koma-h: 1;
}

.piece.koma-major,
.editor-carry.koma-major {
  --koma-w: calc(27 / 28);
  --koma-h: calc(30.5 / 31.5);
}

.piece.koma-gold,
.editor-carry.koma-gold {
  --koma-w: 0.952;
  --koma-h: 0.952;
}

.piece.koma-knight,
.editor-carry.koma-knight {
  --koma-w: 0.932;
  --koma-h: 0.937;
}

.piece.koma-lance,
.editor-carry.koma-lance {
  --koma-w: 0.890;
  --koma-h: 0.902;
}

.piece.koma-pawn,
.editor-carry.koma-pawn {
  --koma-w: 0.834;
  --koma-h: 0.893;
}

.app.piece-style-default .piece,
body.piece-style-default .piece,
.app.piece-style-default .mini-square .piece,
body.piece-style-default .mini-square .piece,
.app.piece-style-default .editor-carry,
body.piece-style-default .editor-carry {
  font-family: "Shippori Mincho", "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  font-weight: 800;
  -webkit-text-stroke: 0;
}

.app.piece-style-mincho .piece,
body.piece-style-mincho .piece,
.app.piece-style-mincho .mini-square .piece,
body.piece-style-mincho .mini-square .piece,
.app.piece-style-mincho .editor-carry,
body.piece-style-mincho .editor-carry {
  font-family: "Yu Mincho", "YuMincho", "Hiragino Mincho ProN", "MS PMincho", "MS Mincho", "Noto Serif JP", serif;
  font-weight: 700;
  -webkit-text-stroke: 0;
}

.app.piece-style-bold .piece,
body.piece-style-bold .piece,
.app.piece-style-bold .mini-square .piece,
body.piece-style-bold .mini-square .piece,
.app.piece-style-bold .editor-carry,
body.piece-style-bold .editor-carry {
  font-family: "Meiryo", "Yu Gothic UI", "YuGothic", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-weight: 900;
  -webkit-text-stroke: 0.55px currentColor;
}

.app.piece-style-rounded .piece,
body.piece-style-rounded .piece,
.app.piece-style-rounded .mini-square .piece,
body.piece-style-rounded .mini-square .piece,
.app.piece-style-rounded .editor-carry,
body.piece-style-rounded .editor-carry {
  font-family: "Yu Gothic", "YuGothic", "Hiragino Kaku Gothic ProN", "Hiragino Sans", "Noto Sans JP", sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  -webkit-text-stroke: 0;
}

.settings-style-hint {
  margin: 10px 0 0;
  color: var(--text-on-dark);
  font-size: 0.85rem;
  line-height: 1.45;
}

.app.view-swapped .piece.sente {
  transform: rotate(180deg);
}

.app.view-swapped .piece.gote {
  transform: none;
}

.piece.promoted {
  color: var(--piece-promote);
}

.piece.gote.promoted {
  color: var(--piece-promote);
}

.controls {
  margin-top: 4px;
  text-align: center;
}

.status,
.kifu-side-status {
  color: var(--text-on-dark);
  font-weight: 800;
}

.ai-thinking-label {
  display: none !important;
}

.hidden {
  display: none !important;
}

.app.ai-thinking .board,
.app.ai-thinking .hand {
  pointer-events: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: 1px solid var(--btn-border);
  border-radius: 999px;
  padding: 10px 22px;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-size: 1rem;
  font-weight: bold;
}

button.secondary {
  background: var(--btn-secondary);
  color: var(--text-on-dark);
  border: 1px solid var(--text-on-dark-muted);
}

button.secondary:hover:not(:disabled) {
  background: var(--btn-secondary-hover);
  color: var(--text-on-dark);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.kimei-overlay-back,
.kimei-overlay-back * {
  pointer-events: none !important;
}

#favSetModal {
  overflow: hidden;
}

.clock-float {
  position: fixed;
  inset: 0;
  z-index: 10220;
  background: transparent;
  pointer-events: none;
}

.clock-float.hidden {
  display: none;
}

.clock-float-card {
  position: fixed;
  left: 24px;
  top: 72px;
  pointer-events: auto;
  width: min(320px, calc(100vw - 24px));
  max-height: min(78vh, 560px);
  overflow: auto;
  padding: 0 10px 10px;
  border-radius: 12px;
  background: var(--surface-light);
  color: var(--text-on-light);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.clock-float-title {
  margin: 0 -10px 8px;
  padding: 8px 12px;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: grab;
  user-select: none;
  touch-action: none;
  background: var(--clock-title-bg);
  border-radius: 12px 12px 0 0;
}

.clock-float-title:active {
  cursor: grabbing;
}

.clock-compact-label,
.clock-compact-check {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 4px 0;
  font-size: 0.86rem;
  font-weight: 700;
}

.clock-compact-label input[type="text"],
.clock-compact-label select,
.clock-compact-label input[type="number"] {
  flex: 1;
  min-width: 0;
  padding: 4px 6px;
  font-size: 0.86rem;
}

.clock-phase-block {
  margin: 6px 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(43, 26, 14, 0.06);
}

.clock-phase-block h3 {
  margin: 0 0 4px;
  font-size: 0.88rem;
}

.clock-phase-hint {
  margin: 0 0 4px;
  font-size: 0.78rem;
  color: var(--text-on-light-muted);
}

.clock-field-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  margin: 4px 0;
  font-size: 0.84rem;
}

.clock-field-row input {
  width: 3.2rem;
  margin: 0;
  padding: 3px 4px;
}

.clock-editor-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.clock-editor-actions button {
  padding: 6px 10px;
  font-size: 0.86rem;
}

.clock-manage-card {
  max-width: min(92vw, 480px);
  text-align: left;
  padding: 16px;
}

.clock-manage-help {
  margin: 0 0 8px;
  font-size: 0.84rem;
  color: var(--text-on-light-muted);
}

.clock-manage-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(50vh, 360px);
  overflow: auto;
}

.clock-manage-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.clock-manage-name {
  flex: 1 1 8rem;
  font-weight: 700;
  font-size: 0.86rem;
  color: var(--text-on-light);
}

.clock-manage-row button {
  padding: 4px 8px;
  font-size: 0.78rem;
}

.net-wait-side-board {
  display: flex;
  justify-content: center;
  margin: 0 auto 8px;
}

#netWaitSideStep .catalog-mini,
#netWaitingSelfStep .catalog-mini,
#netWaitDock .catalog-mini {
  width: min(196px, 70vw);
  max-width: 196px;
  margin-inline: auto;
}

.clock-preset-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(8.6em, 1fr));
  gap: 5px;
  max-height: none;
  overflow: visible;
  margin: 6px 0 4px;
}

.clock-preset-pick {
  min-width: 0;
  text-align: center;
  padding: 6px 4px;
  font-size: 0.74rem;
  line-height: 1.25;
  opacity: 0.78;
  box-shadow: none;
}

.clock-preset-pick.active-toggle {
  opacity: 1;
  background: var(--clock-pick-on-bg);
  color: var(--clock-pick-on-ink);
  border: 1px solid var(--clock-pick-on-ring);
  box-shadow: 0 0 0 2px rgba(212, 180, 106, 0.35);
  font-weight: 800;
}

html.theme-standard .clock-preset-pick.active-toggle {
  box-shadow: inset 0 0 0 2px var(--clock-pick-on-ring);
}

.clock-pick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 6px 0 0;
}

.clock-pick-actions button {
  padding: 6px 10px;
  font-size: 0.84rem;
}

.net-clock-pick h3 {
  margin: 4px 0 2px;
  font-size: 1rem;
}

.net-dialog {
  min-width: min(92vw, 540px);
  max-width: min(96vw, 560px);
  max-height: 92vh;
  overflow: auto;
  text-align: left;
}

.clock-phase-block {
  margin: 6px 0;
  padding: 6px 8px;
  border-radius: 8px;
  background: rgba(43, 26, 14, 0.06);
}

.clock-phase-block h3 {
  margin: 0 0 4px;
  font-size: 0.88rem;
}

.clock-field-row {
  margin: 4px 0;
}

.clock-field-row input {
  width: 3.2rem;
  margin: 0 4px;
}

.modal.hidden {
  display: none;
}

.settings-modal {
  align-items: flex-start;
  justify-content: center;
  padding-top: max(8px, env(safe-area-inset-top));
  background: rgba(8, 6, 12, 0.22);
}

.settings-card {
  min-width: 0;
  width: min(92vw, 420px);
  max-height: none;
  padding: 8px 10px 10px;
  text-align: left;
  overflow: visible;
  cursor: grab;
}

.settings-card-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
  cursor: grab;
  touch-action: none;
}

.settings-card-head h2 {
  margin: 0;
  font-size: 0.92rem;
}

.settings-card-head button {
  margin: 0;
  padding: 4px 10px;
  min-width: 3.6em;
}

.settings-grid {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.settings-pair,
.settings-sound-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.settings-pair > *,
.settings-sound-row > .position-label {
  flex: 1 1 0;
  min-width: 0;
}

.settings-sound-row button {
  flex: 0 0 auto;
  padding: 4px 10px;
  margin: 0;
}

.settings-grid .position-label,
.settings-grid .board-bright-ctrl,
.settings-grid .fx-vol-ctrl,
.settings-grid .board-see-ctrl {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin: 0;
  white-space: nowrap;
  font-size: 0.86rem;
}

.settings-grid .position-label select {
  padding: 3px 6px;
  min-width: 0;
  max-width: 10.5em;
  flex: 1 1 auto;
}

.settings-grid #settingsPieceSoundId,
.settings-grid #settingsOnijinSoundId {
  max-width: 7.2em;
}

.settings-grid #settingsMoveHints {
  min-width: 3.4em;
  padding: 4px 10px;
  margin: 0;
}

.settings-grid #settingsSoundPreview,
.settings-grid #settingsOnijinPreview {
  align-self: center;
  padding: 4px 10px;
}

.board-bright-ctrl,
.fx-vol-ctrl,
.board-see-ctrl {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-weight: 700;
  white-space: nowrap;
}

.board-bright-ctrl button,
.fx-vol-ctrl button,
.board-see-ctrl button {
  min-width: 1.8em;
  padding: 4px 8px;
}

.board-bright-ctrl span,
.fx-vol-ctrl span,
.board-see-ctrl span {
  min-width: 2.2em;
  text-align: center;
}

.modal-card {
  background: var(--surface-light);
  color: var(--text-on-light);
  padding: 28px 24px;
  border-radius: 16px;
  text-align: center;
  min-width: min(90vw, 320px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.4);
}

.modal-card h2,
.modal-card h3,
.modal-card p,
.modal-card label,
.modal-card .editor-label,
.modal-card .editor-label strong {
  color: var(--text-on-light);
}

#resultTitle.result-you-win,
#resultTitle.result-you-lose {
  font-size: 1.85rem;
  letter-spacing: 0.06em;
  text-align: center;
}

#resultMessage {
  text-align: center;
  font-size: 1.1rem;
}

.modal-card button.secondary {
  background: var(--modal-secondary-bg);
  color: var(--text-on-light);
  border: 1px solid var(--control-border);
}

.modal-card button.secondary:hover {
  background: var(--modal-secondary-hover);
  color: var(--text-on-light);
}

.modal-card button:disabled,
.modal-card button.secondary:disabled {
  opacity: 1;
  background: var(--modal-disabled-bg);
  color: var(--text-on-light-disabled);
  border: 1px solid var(--control-border);
}

.modal-card input[type="text"],
.modal-card input:not([type]),
.modal-card textarea {
  background: var(--control-light);
  color: var(--text-on-light);
  border: 1px solid var(--control-border);
  font: inherit;
}

.modal-card input::placeholder,
.modal-card textarea::placeholder {
  color: var(--text-on-light-muted);
  opacity: 1;
}

.modal-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
}

.save-title-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 12px;
  min-width: 0;
}

.save-title-row input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.action-notice {
  position: fixed;
  left: 50%;
  bottom: max(16px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 12000;
  max-width: min(92vw, 420px);
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(20, 18, 32, 0.92);
  color: var(--text-on-dark);
  font-size: 0.92rem;
  font-weight: 800;
  text-align: center;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}

.action-notice.is-error {
  background: rgba(90, 24, 40, 0.94);
}

.action-notice.hidden {
  display: none !important;
}

.editor-bar {
  margin-top: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(246, 236, 214, 0.16);
  border: 1px solid rgba(255, 244, 194, 0.45);
}

.editor-bar button {
  padding: 8px 16px;
  font-size: 0.92rem;
}

.editor-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin-bottom: 8px;
  align-items: center;
}

.editor-label {
  color: var(--text-on-dark);
  font-size: 0.95rem;
  font-weight: 700;
}

.editor-label strong {
  color: var(--text-on-dark);
}

.editor-setting {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-on-dark);
  font-size: 0.95rem;
  font-weight: 700;
}

.editor-setting .bgm-toggle {
  min-width: 3.6em;
  min-height: 32px;
  padding: 4px 10px;
  font-size: 0.82rem;
}

.editor-setting select option {
  background: #fff8e8;
  color: #2b1a0e;
}

.editor-palette {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 8px 0 12px;
}

.editor-palette-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
  align-items: center;
}

.editor-box-piece {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 52px;
  padding: 0;
  border-radius: 8px;
  background: transparent;
  border: 1px solid transparent;
}

.editor-box-piece.selected,
.hand-piece.selected {
  background: transparent;
  border-color: transparent;
}

.editor-box-piece .piece {
  width: calc(100% * var(--koma-w) * var(--koma-scale-x));
  height: calc(100% * var(--koma-h));
  font-size: calc(1.05rem * var(--koma-glyph));
}

.editor-trash {
  min-width: 88px;
}

.editor-sfen-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin: 8px 0 12px;
}

.editor-sfen-row input {
  min-width: min(70vw, 420px);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid #fff4c2;
  background: #fff8e8;
  color: #2b1a0e;
  font-family: Consolas, monospace;
  font-size: 0.8rem;
}

.editor-bar button.secondary {
  color: var(--text-on-dark);
  border-color: var(--text-on-dark-muted);
  background: rgba(43, 26, 14, 0.45);
}

.editor-bar button.secondary:hover {
  background: rgba(43, 26, 14, 0.65);
  color: var(--text-on-dark);
}

.editor-bar button.active-toggle {
  background: #fff4c2;
  color: #2b1a0e;
}

.editor-bar button:disabled,
.editor-bar button.secondary:disabled {
  opacity: 1;
  color: var(--text-on-dark-disabled);
  border-color: #c4a060;
  background: rgba(43, 26, 14, 0.4);
}

.editor-actions button#editorPlayAi {
  font-size: 1.05rem;
}

button:disabled {
  opacity: 1;
  cursor: default;
  color: var(--btn-disabled-ink);
  background: var(--btn-disabled-bg);
}

button.secondary:disabled {
  color: var(--text-on-dark-disabled);
  background: rgba(43, 26, 14, 0.4);
  border-color: var(--text-on-dark-muted);
}

.hand-edit {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  margin-bottom: 4px;
  max-width: 100%;
}

.hand-edit-btn {
  position: relative;
  flex: 0 0 auto;
  width: 22px;
  min-width: 22px;
  height: 22px;
  padding: 0;
  font-size: 0.75rem;
  line-height: 1;
  border-radius: 6px;
}

.hand-edit-btn::before {
  content: "";
  position: absolute;
  inset: -10px -4px;
}

.hand-edit .hand-piece {
  width: 32px;
  min-width: 32px;
  height: 36px;
  padding: 0;
}

.hand-edit .piece {
  width: calc(24px * var(--koma-w) * var(--koma-scale-x));
  height: calc(28px * var(--koma-h));
  font-size: calc(0.72rem * var(--koma-glyph));
}

.kifu-dock {
  position: absolute;
  z-index: 3;
  top: 28px;
  right: 0;
  left: auto;
  width: 140px;
  height: var(--board-height);
  transform: translateX(calc(100% + 112px));
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  min-height: 0;
  pointer-events: none;
}

.kifu-dock > * {
  pointer-events: auto;
}

.kifu-side-status {
  margin: 0;
  padding: 0 2px;
  font-size: 0.8rem;
  line-height: 1.3;
  text-align: center;
  flex: 0 0 auto;
}

.kifu-side-opening {
  margin: 0;
  padding: 0 2px;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  font-size: 0.74rem;
  line-height: 1.3;
  text-align: center;
  flex: 0 0 auto;
}

.app.editing .kifu-dock {
  display: none;
}

.kifu-panel {
  display: flex;
  flex-direction: column;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  margin: 0;
  padding: 6px 4px 4px;
  border-radius: 10px;
  background: rgba(246, 236, 214, 0.16);
  border: 1px solid rgba(243, 220, 176, 0.35);
  color: var(--text-on-dark);
}

.kifu-panel.hidden {
  display: none;
}

.kifu-show-button {
  writing-mode: horizontal-tb;
  flex: 1 1 auto;
  align-self: stretch;
  min-width: 5.4rem;
  max-width: 8.6rem;
  padding: 10px 8px;
  font-size: 0.82rem;
  line-height: 1.35;
  white-space: normal;
  height: auto;
}

.app.editing .kifu-show-button {
  display: none !important;
}

.kifu-panel-head {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 4px;
}

.kifu-ply-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding-left: 8px;
}

#kifuClose {
  flex: 0 0 auto;
}

.kifu-ply {
  margin: 0;
  text-align: left;
  font-size: 0.75rem;
  color: var(--text-on-dark);
  line-height: 1.3;
}

.kifu-nav {
  display: flex;
  flex-wrap: nowrap;
  gap: 3px;
  justify-content: center;
}

.kifu-nav button {
  position: relative;
  min-width: 0;
  padding: 3px 6px;
  font-size: 0.72rem;
  border-radius: 8px;
}

.kifu-nav button::before {
  content: "";
  position: absolute;
  inset: -10px -2px;
}

#historyUndoButton,
#historyRedoButton {
  position: relative;
}

#historyUndoButton::before,
#historyRedoButton::before {
  content: "";
  position: absolute;
  inset: -8px -4px;
}

.kifu-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: auto;
  overflow-y: auto;
  margin: 0;
  padding-left: 6px;
  padding-right: 2px;
  line-height: 1.3;
  overscroll-behavior: contain;
}

.kifu-empty,
.kifu-item {
  margin: 0;
}

.kifu-empty {
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--text-on-dark-muted);
}

.kifu-game-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 4px;
}

.kifu-game-tab {
  flex: 1 1 0;
  min-width: 0;
  margin: 0;
  padding: 3px 4px;
  font-size: 0.68rem;
  border-radius: 999px;
  background: transparent;
  color: var(--text-on-dark);
}

.kifu-game-tab.is-on {
  background: #141014;
  color: #f6f2ea;
}

.kifu-item {
  width: 100%;
  display: block;
  text-align: left;
  border-radius: 10px;
  background: transparent;
  color: var(--text-on-dark);
  border: 0;
  padding: 3px 4px;
  font: inherit;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  word-break: keep-all;
  cursor: pointer;
}

.kifu-move-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 4px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
}

.kifu-move-row > .kifu-item {
  width: auto;
  flex: 1 1 auto;
  min-width: min-content;
  max-width: 100%;
  white-space: nowrap;
}

.kifu-branch-count {
  flex: 0 0 auto;
  min-width: 2.2em;
  margin: 0;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1px solid rgba(243, 220, 176, 0.55);
  background: rgba(20, 16, 20, 0.45);
  color: #fff4c2;
  font-size: 0.78em;
  font-weight: 800;
  line-height: 1.3;
  cursor: pointer;
}

.kifu-branch-count.is-open {
  background: #141014;
  color: #fff4c2;
}

.kifu-branch-list {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 1px;
  min-width: 0;
  max-width: 100%;
  flex: 1 1 7.5rem;
}

.kifu-branch-list .kifu-item {
  width: 100%;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kifu-item.variation {
  padding-left: 14px;
  color: var(--text-on-dark-muted);
}

.kifu-item.result-item {
  font-style: italic;
}

.kifu-item.variation.current,
.kifu-item.result-item.current {
  color: #f6f2ea;
}

.kifu-panel-foot {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  justify-content: center;
  margin-top: 4px;
}

.kifu-panel-foot button {
  min-width: 0;
  padding: 3px 6px;
  font-size: 0.68rem;
  border-radius: 8px;
}

.app.kifu-open:not(.editing) {
  padding-right: 270px;
  padding-left: 120px;
}

.app.kifu-open.view-swapped:not(.editing) {
  padding-right: 270px;
  padding-left: 120px;
}

.app.kifu-open:not(.editing) .sente-area {
  width: 96px;
  overflow: hidden;
}

.app.kifu-open:not(.editing) .sente-area.kifu-open {
  justify-content: flex-end;
}

.app.kifu-open:not(.editing) .sente-area .hand {
  flex: 0 0 auto;
  margin: 4px 0 8px;
}

.app.editing .kifu-panel {
  display: none;
}

.import-hint {
  margin: 0 0 10px;
  color: var(--text-on-dark);
  font-size: 0.82rem;
  line-height: 1.5;
  text-align: center;
}

.net-status {
  margin: 0 0 8px;
  text-align: center;
  color: var(--text-on-dark-muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.pwa-update-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  border-radius: 10px;
  background: rgba(20, 18, 32, 0.72);
  color: var(--text-on-dark);
  font-size: 0.9rem;
  font-weight: 700;
  text-align: center;
}

.pwa-update-banner.hidden {
  display: none !important;
}

.pwa-update-banner p {
  margin: 0;
}

.pwa-update-banner button {
  flex: 0 0 auto;
}

.match-result-banner {
  margin: 0 0 6px;
  text-align: center;
  color: var(--text-on-dark);
  font-size: 0.95rem;
  font-weight: 800;
  line-height: 1.35;
}

.match-result-banner.is-win {
  color: #ffe7a8;
}

.match-result-banner.is-lose {
  color: #ffc4c4;
}

.rematch-wait-row {
  display: flex;
  justify-content: center;
  margin: 0 0 10px;
}

.rematch-wait-row.hidden {
  display: none;
}

.net-clock {
  margin: 4px 0 0;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--text-on-dark);
  white-space: pre-line;
  line-height: 1.25;
}

.catalog-clock-pick {
  margin: 0 0 10px;
  padding: 6px 8px;
  border: 1px solid #d8c4a4;
  border-radius: 10px;
  background: #fffaf0;
}

.catalog-clock-selected {
  margin: 0 0 4px;
  font-size: 0.8rem;
  line-height: 1.35;
}

.catalog-clock-pick .clock-preset-list {
  max-height: 9.5rem;
  overflow: auto;
}

.net-clock.net-clock-active {
  color: #ffe7a8;
}

.net-clock-rule {
  margin: 0 0 10px;
  text-align: center;
  color: var(--text-on-dark-muted);
  font-size: 0.84rem;
  line-height: 1.45;
}

.status.photo-outline,
.turn-hint.photo-outline,
.net-status.photo-outline,
.match-result-banner.photo-outline,
.ai-thinking-label.photo-outline,
.net-clock-rule.photo-outline,
.file-labels.photo-outline,
.rank-labels.photo-outline,
.kifu-ply,
.kifu-empty,
.kifu-item,
.position-label.photo-outline,
.net-presence-count,
.net-wait-count,
.editor-turn-status.photo-outline {
  color: #f6f2ea;
  -webkit-text-stroke: 0.45px rgba(16, 12, 14, 0.92);
  paint-order: stroke fill;
  text-shadow:
    -1px -1px 0 #141014,
    1px -1px 0 #141014,
    -1px 1px 0 #141014,
    1px 1px 0 #141014,
    0 0 3px #141014;
}

.net-count-wrap {
  display: flex;
  flex-direction: row;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 2px 16px;
  flex: 1 1 100%;
  order: 6;
  min-width: 0;
  line-height: 1.25;
}

.net-presence-count,
.net-wait-count {
  white-space: nowrap;
  flex: 0 0 auto;
}

.control-row-start #positionCatalogButton {
  order: 1;
}

.control-row-start #resetButton {
  order: 2;
}

.control-row-start #netPlayButton {
  order: 3;
}

.control-row-start #editButton {
  order: 4;
}

.control-row-start #netLeaveButton {
  order: 5;
}

.board-side-tools {
  display: none;
}

.position-label.photo-outline .seat-toggle {
  -webkit-text-stroke: 0;
  text-shadow: none;
  paint-order: normal;
}

.kifu-item.current,
.kifu-item.variation.current,
.kifu-item.result-item.current {
  background: #141014;
  color: #f6f2ea;
  border-radius: 999px;
  -webkit-text-stroke: 0;
  text-shadow: none;
  paint-order: normal;
  font-weight: 800;
}

.net-play-entry {
  display: contents;
}

.net-wait-count,
.net-wait-count-modal {
  font-weight: 800;
  color: #fff4c2;
}

.net-wait-count-modal {
  margin: 0 0 8px;
  color: var(--text-on-light);
  font-size: 1.05rem;
}

.net-wait-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 12px;
  max-height: min(52vh, 520px);
  overflow: auto;
  margin: 0 0 12px;
}

.net-wait-card {
  background: rgba(0, 0, 0, 0.06);
  border: 1px solid rgba(139, 98, 48, 0.4);
  border-radius: 12px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.net-wait-mini {
  cursor: default;
}

.net-wait-mini:hover {
  background: #f3e6c8;
}

.net-wait-side {
  margin: 0;
  font-weight: 800;
  color: var(--text-on-light);
}

.net-config-details {
  margin: 12px 0;
  color: var(--text-on-light);
}

.net-help {
  margin: 0 0 12px;
  color: var(--text-on-light-muted);
  font-size: 0.88rem;
  line-height: 1.5;
}

.net-code {
  min-height: 1.4em;
  margin: 8px 0 12px;
  font-size: 1.4rem;
  letter-spacing: 0.18em;
  text-align: center;
  font-weight: 800;
  color: var(--text-on-light);
}

.app.net-play .control-row-start,
.app.net-play .home-fav-set-bar,
.app.net-play .control-row-seats,
.app.net-play .control-row-tools,
.app.net-play .control-row-end > :not(#resignButton),
.app.net-play .kifu-nav,
.app.net-play .kifu-panel-foot,
.app.net-play .history-btn,
.app.net-play #kifuTabPrev,
.app.net-play #positionCatalogButton,
.app.net-play #resetButton,
.app.net-play #netPlayButton,
.app.net-play #editButton,
.app.net-play #interruptButton,
.app.net-play #swapButton,
.app.net-play #mirrorButton,
.app.net-play #kifuCopyButton,
.app.net-play #kifuSaveButton,
.app.net-play #positionCopyButton,
.app.net-play #takeBackButton,
.app.net-play #importFileButton,
.app.net-play #importPasteButton,
.app.net-play #kifuShareButton,
.app.net-play #positionShareButton,
.app.net-play #positionRegisterButton,
.app.net-play #kifuEdit,
.app.net-play #kifuPlayAi,
.app.net-play #kifuCopy,
.app.net-play #kifuShare,
.app.net-play #kifuStart,
.app.net-play #kifuPrev,
.app.net-play #kifuNext,
.app.net-play #kifuEnd,
.app.net-play #netLeaveButton,
.app.net-play #aiThinking,
.app.net-play .net-play-entry {
  display: none !important;
}

.app.net-play #resignButton {
  display: inline-flex !important;
  margin-left: auto;
  justify-self: end;
  width: auto;
}

.app.net-play .onijin-button {
  display: inline-flex;
}

.app.net-play .onijin-button.is-empty,
.onijin-button:disabled {
  opacity: 0.45;
}

.net-wait-dock {
  margin: 28px auto 0;
  max-width: 420px;
  padding: 16px;
  border-radius: 16px;
  background: var(--surface-light);
  color: var(--text-on-light);
  text-align: center;
}

.net-wait-dock h2 {
  margin: 0 0 8px;
  font-size: 1.1rem;
}

.net-wait-dock-help {
  margin: 0 0 12px;
  font-size: 0.88rem;
  line-height: 1.5;
  color: var(--text-on-light-muted);
}

.net-wait-dock .catalog-mini {
  width: 100%;
}

.file-drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  background: rgba(26, 13, 8, 0.72);
  color: var(--text-on-dark);
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.file-drop-overlay.hidden {
  display: none;
}

.app.file-drop-active {
  outline: 4px solid #fff4c2;
  outline-offset: -4px;
}

/* 721-800px: 左右の余白（通常 96+220px / 編集 140+140px）と盤の目盛り分を引いた幅に盤を収める */
@media (min-width: 721px) and (max-width: 800px) {
  :root {
    --board-fit: min(calc(100vw - 358px), calc(68vh / var(--sq-aspect)), 640px);
  }

  .app.editing {
    --board-fit: min(calc(100vw - 324px), calc(68vh / var(--sq-aspect)), 640px);
  }

  /* 盤が小さくなっても編集用の持ち駒欄（最下段の歩）が切れないよう高さに下限を設ける */
  .app.editing .gote-area,
  .app.editing .sente-area {
    height: max(calc(var(--board-height) * 0.56), 228px);
  }
}

@media (max-width: 800px) {
  .app {
    padding: 16px 80px 32px;
  }

  .app.editing {
    padding-left: 140px;
    padding-right: 140px;
  }

  .app.editing .gote-area,
  .app.editing .sente-area,
  .app.editing .editor-bench {
    width: 118px;
  }

  .app.editing .hand {
    gap: 1px;
  }

  .app.editing .hand-edit {
    gap: 2px;
  }

  .app.editing .hand-edit .hand-piece {
    height: 26px;
    padding: 0 1px;
  }

  .app.editing .hand-edit .piece {
    width: calc(20px * var(--koma-w) * var(--koma-scale-x));
    height: calc(24px * var(--koma-h));
    font-size: calc(0.72rem * var(--koma-glyph));
  }

  .app.editing .hand-edit-btn {
    width: 20px;
    min-width: 20px;
    height: 22px;
  }

  .app.kifu-open:not(.editing),
  .app.kifu-open.view-swapped:not(.editing),
  .app:not(.editing),
  .app.view-swapped:not(.editing) {
    padding-right: 220px;
    padding-left: 96px;
  }

  .gote-area,
  .sente-area {
    width: 72px;
    top: 24px;
    height: var(--board-height);
    overflow: hidden;
  }

  .app.kifu-open:not(.editing) .sente-area {
    width: 72px;
  }

  .kifu-dock {
    width: 118px;
    transform: translateX(calc(100% + 88px));
  }

  .kifu-panel {
    width: 100%;
  }

  .sente-main {
    width: 72px;
    flex-basis: 72px;
  }

  .hand-edit-btn {
    width: 18px;
    min-width: 18px;
    height: 22px;
    font-size: 0.7rem;
  }

  .hand-edit .hand-piece {
    width: 28px;
    min-width: 28px;
    height: 32px;
  }

  .player-area {
    padding: 6px 4px;
  }

  .hand-piece {
    width: 34px;
    height: 40px;
  }

  .hand-piece .piece {
    font-size: calc(0.85rem * var(--koma-glyph));
  }

  .player-badge {
    padding: 4px 6px;
    letter-spacing: 0.08em;
    font-size: 0.75rem;
  }

  .turn-hint {
    margin: 0;
  }
}

.catalog-modal {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  overflow: hidden;
}

#authModal .editor-label {
  display: block;
  text-align: left;
  margin: 8px 0 4px;
}

#authModal input {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

#authModal .modal-actions {
  flex-wrap: wrap;
}

#authModal .modal-actions button {
  white-space: nowrap;
}

button.is-inactive {
  opacity: 0.48;
}

.catalog-dialog {
  position: relative;
  min-width: 0;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
  text-align: left;
  color: var(--text-on-light);
  border-radius: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  container-type: inline-size;
}

.catalog-dialog > * {
  flex: 0 0 auto;
}

.catalog-dialog > .catalog-dialog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  touch-action: pan-y;
}

.catalog-dismiss-float {
  position: absolute;
  top: 6px;
  right: 6px;
  z-index: 20;
}

.catalog-modal .catalog-dialog-head {
  position: static;
  z-index: auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  margin: -8px 44px 8px 0;
  padding: 4px 0 8px 4px;
  background: transparent;
}

.catalog-dialog-head h2 {
  margin: 0;
  flex: 1 1 auto;
  min-width: 0;
}

#catalogOfficialExport {
  flex: 0 0 auto;
  font-size: 0.85rem;
  white-space: nowrap;
}

.catalog-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  margin: 0 0 8px;
  padding: 4px 0 8px 4px;
}

.catalog-dismiss {
  flex: 0 0 auto;
  width: 44px;
  min-width: 44px;
  height: 44px;
  margin: 0;
  padding: 0;
  font-size: 1.7rem;
  line-height: 1;
  font-weight: 700;
  border-radius: 10px;
}

.catalog-dialog h2 {
  color: var(--text-on-light);
  margin: 0 0 10px;
}

.catalog-tabs,
.catalog-categories,
.catalog-filter-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 8px 0 12px;
}

.catalog-filters {
  margin: 4px 0 10px;
}

.catalog-filters > summary {
  display: none;
  cursor: pointer;
  list-style: none;
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--text-on-light);
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(43, 26, 14, 0.08);
  border: 1px solid rgba(90, 50, 20, 0.28);
}

.catalog-filters > summary::-webkit-details-marker {
  display: none;
}

.catalog-filter-stack {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 4px 0 10px;
}

.catalog-filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 10px;
}

.catalog-filter-heading {
  flex: 0 0 auto;
  min-width: 5.5em;
  font-weight: 800;
  color: var(--text-on-light);
  font-size: 0.82rem;
}

.catalog-filter-row .catalog-filter-buttons,
.catalog-filter-row .catalog-categories {
  flex: 1 1 12rem;
  margin: 0;
}

.catalog-filter-search input[type="search"] {
  flex: 1 1 12rem;
  min-width: 8rem;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #5a3214;
  background: #fff8e8;
  color: #2b1a0e;
}

.catalog-dialog button:not(.catalog-mini) {
  background: #efe0c0;
  color: #2b1a0e;
  border: 1px solid #5a3214;
  font-weight: 700;
}

.catalog-dialog button.secondary:not(.catalog-mini) {
  background: #efe0c0;
  color: #2b1a0e;
  border: 1px solid #5a3214;
}

.catalog-dialog button:not(.catalog-mini):hover {
  background: #e4d0a4;
}

.catalog-dialog button.active-toggle:not(.catalog-mini) {
  background: #5a3214;
  color: #fff4c2;
  border-color: #2b1a0e;
}

.catalog-dialog button:disabled:not(.catalog-mini) {
  opacity: 1;
  background: #ddd3ba;
  color: #4a3218;
  border-color: #8b6230;
}

.catalog-children {
  margin-top: -4px;
  padding: 8px;
  border-radius: 10px;
  background: #f3e6c8;
  border: 1px solid #8b6230;
}

.catalog-filter-hint {
  margin: 0 0 8px;
  color: var(--text-on-light);
  font-size: 0.95rem;
}

#catalogEntryHint {
  line-height: 1.45;
  font-size: 0.86rem;
  max-width: 100%;
  overflow-wrap: break-word;
}

.catalog-view-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin: 0 0 10px;
}

.catalog-col-ctrl,
.catalog-size-ctrl {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
}

.catalog-col-ctrl > span,
.catalog-size-ctrl > span {
  font-weight: 800;
  color: var(--text-on-light);
}

#catalogSizeLabel {
  min-width: 2.4em;
  text-align: center;
  font-weight: 800;
}

.catalog-view-ctrl button {
  padding: 6px 10px;
  font-size: 0.82rem;
}
  font-weight: 700;
}

.category-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  margin: 8px 0 16px;
  max-height: 40vh;
  overflow: auto;
}

.category-picker-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border-radius: 8px;
  background: #efe4c8;
  color: var(--text-on-light);
  border: 1px solid #8b6230;
}

.category-picker-group label {
  color: var(--text-on-light);
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.category-picker-child {
  margin-left: 16px;
  font-size: 0.9rem;
  color: var(--text-on-light);
}

.category-edit-dialog {
  min-width: min(92vw, 760px);
  text-align: left;
  color: var(--text-on-light);
}

.category-edit-dialog h2,
.category-edit-dialog h3 {
  color: var(--text-on-light);
  margin: 0 0 8px;
}

.category-edit-help,
.category-edit-hint {
  margin: 0 0 12px;
  color: var(--text-on-light-muted);
  font-size: 0.92rem;
  font-weight: 700;
}

.category-edit-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin: 12px 0 16px;
}

.category-edit-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-height: 180px;
  max-height: 40vh;
  overflow: auto;
  margin-bottom: 8px;
  padding: 8px;
  border-radius: 10px;
  background: #f3e6c8;
  border: 1px solid #8b6230;
}

.category-edit-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 40px;
  padding: 6px 10px;
  border-radius: 8px;
  border: 1px solid #8b6230;
  background: #fff8e8;
  color: #2b1a0e;
  font-weight: 700;
  cursor: grab;
  text-align: left;
  user-select: none;
}

.category-edit-children .category-edit-item {
  margin-left: 18px;
  width: calc(100% - 18px);
  border-left: 4px solid #8b6230;
}

.category-edit-item.selected {
  background: #5a3214;
  color: #fff4c2;
  border-color: #2b1a0e;
}

.category-edit-item.dragging {
  opacity: 0.55;
}

.category-edit-item input {
  flex: 1;
  min-width: 0;
  font: inherit;
  font-weight: 700;
  color: #2b1a0e;
  background: #fff;
  border: 1px solid #5a3214;
  border-radius: 6px;
  padding: 4px 8px;
}

.category-edit-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.category-edit-actions button,
.category-edit-dialog #categoryEditClose {
  background: #efe0c0;
  color: #2b1a0e;
  border: 1px solid #5a3214;
  font-weight: 700;
}

.category-edit-actions button:hover,
.category-edit-dialog #categoryEditClose:hover {
  background: #e4d0a4;
}

.category-edit-status,
.category-delete-bar p {
  margin: 0 0 10px;
  color: #7a2a12;
  font-size: 0.9rem;
  font-weight: 700;
}

.category-delete-bar {
  margin: 0 0 12px;
  padding: 10px;
  border-radius: 10px;
  background: #f8ead0;
  border: 1px solid #8b6230;
}

.category-delete-bar.hidden {
  display: none;
}

.category-delete-bar select {
  width: 100%;
  margin: 0 0 10px;
  min-height: 36px;
}

.catalog-dialog {
  padding-left: 6px;
  padding-right: 6px;
}

.catalog-dialog .catalog-grid {
  gap: 4px;
}

.catalog-dialog .catalog-card-item {
  padding: 3px;
}

.catalog-dialog[data-cols="2"] .mini-files {
  font-size: 0.58rem;
}

.catalog-virtual {
  position: relative;
  min-width: 0;
  width: 100%;
  overflow: hidden;
}

.catalog-virtual-spacer {
  width: 1px;
  pointer-events: none;
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(var(--catalog-cols, 3), max-content);
  justify-content: start;
  gap: 4px;
  min-height: min-content;
  min-width: 0;
  align-items: start;
  overflow: visible;
  padding: 0;
}

.catalog-virtual-window {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  width: max-content;
  min-height: 0;
  overflow: visible;
  will-change: transform;
}

.catalog-virtual-window > .catalog-card-item {
  position: absolute;
  top: 0;
  left: 0;
}

.catalog-hscroll {
  flex: 0 0 auto;
  width: 100%;
  max-width: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  height: 14px;
  background: rgba(255, 248, 232, 0.92);
  border-top: 1px solid rgba(90, 50, 20, 0.25);
  z-index: 8;
}

.catalog-hscroll-inner {
  height: 1px;
}

.catalog-card-item {
  background: rgba(0, 0, 0, 0.08);
  border-radius: 8px;
  padding: 3px;
  border: 1px solid rgba(139, 98, 48, 0.35);
  min-width: 0;
  width: max-content;
  max-width: none;
  overflow: visible;
}

.catalog-card-item.official {
  box-shadow: inset 0 0 0 1px rgba(180, 140, 70, 0.4);
}

.catalog-mini {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  width: var(--catalog-board, calc(100% * min(1, var(--catalog-frac, 0.76))));
  max-width: none;
  height: auto;
  margin: 0;
  padding: 4px 4px 3px;
  border-radius: 12px;
  border: 1px solid #8b6230;
  background: #f3e6c8;
  cursor: pointer;
  color: #2b1a0e;
  font-weight: 700;
  appearance: none;
  box-shadow: none;
  container-type: inline-size;
}

.catalog-mini:hover {
  background: #efe0c0;
}

.mini-board-chrome {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto auto;
  align-items: start;
  width: 100%;
  flex: 0 0 auto;
}

.mini-files {
  grid-column: 1;
  grid-row: 1;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  color: #2b1a0e;
  font-size: clamp(0.42rem, 1.8vw, 0.7rem);
  font-weight: 800;
  line-height: 1;
  text-align: center;
  align-items: center;
}

.mini-board {
  --koma-mini-fill-w: 100cqw;
  --koma-mini-fill-h: 100cqh;
  --koma-mini-glyph: 104cqmin;
  --koma-mini-glyph-gold: 101cqmin;
  --koma-mini-glyph-knight: 100cqmin;
  --koma-mini-glyph-major: 101cqmin;
  --koma-mini-glyph-nudge: -2%;
  --koma-mini-stack: 0.58em;
  --koma-mini-sq: #E8BE83;
  position: relative;
  grid-column: 1;
  grid-row: 2;
  align-self: start;
  width: 100%;
  aspect-ratio: 1 / var(--sq-aspect);
  height: auto;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
  container-type: inline-size;
  overflow: hidden;
  background: var(--koma-mini-sq);
  background-image: none;
  border: 3px solid var(--wood-dark);
  box-sizing: border-box;
}

.mini-ranks {
  display: none;
}

.mini-square {
  position: relative;
  z-index: 1;
  min-width: 0;
  min-height: 0;
  border: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  overflow: hidden;
  background: var(--koma-mini-sq);
  container-type: size;
}

.mini-square .piece,
.mini-square .piece.gote,
.app.view-swapped .mini-square .piece.sente,
.app.view-swapped .mini-square .piece.gote {
  align-self: center;
}

.mini-square .piece,
.mini-square .piece.koma-king,
.mini-square .piece.koma-major,
.mini-square .piece.koma-gold,
.mini-square .piece.koma-knight,
.mini-square .piece.koma-lance,
.mini-square .piece.koma-pawn,
.app.view-swapped .mini-square .piece.sente,
.app.view-swapped .mini-square .piece.gote,
.app.view-swapped .catalog-mini .piece {
  --koma-w: 1;
  --koma-h: 1;
  --koma-scale-x: 1;
  --koma-glyph-nudge: var(--koma-mini-glyph-nudge);
  width: var(--koma-mini-fill-w);
  height: var(--koma-mini-fill-h);
  max-width: 100%;
  max-height: 100%;
  flex-shrink: 0;
  font-size: var(--koma-mini-glyph);
  line-height: 1;
  letter-spacing: inherit;
  opacity: 1;
  clip-path: none;
  -webkit-clip-path: none;
  background: transparent;
  border: none;
  box-shadow: none;
  filter: none;
  isolation: auto;
}

.mini-square .piece.koma-gold {
  font-size: var(--koma-mini-glyph-gold);
}

.mini-square .piece.koma-knight {
  font-size: var(--koma-mini-glyph-knight);
}

.mini-square .piece.koma-major {
  font-size: var(--koma-mini-glyph-major);
}

.mini-square .piece::before,
.app.view-swapped .catalog-mini .piece::before {
  content: none;
  display: none;
  background: none;
  clip-path: none;
  -webkit-clip-path: none;
}

.mini-square .piece-glyph {
  transform: translateY(var(--koma-mini-glyph-nudge));
}

.mini-square .piece-glyph,
.mini-square .piece-stack {
  font-size: 1em;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
}

.mini-square .piece-stack {
  line-height: 0.82;
}

.mini-square .piece-stack-top,
.mini-square .piece-stack-bottom {
  font-size: var(--koma-mini-stack);
}

@container (max-width: 38px) {
  .mini-square .piece {
    --koma-mini-glyph: 98cqmin;
    --koma-mini-glyph-gold: 95cqmin;
    --koma-mini-glyph-knight: 94cqmin;
    --koma-mini-glyph-major: 95cqmin;
    --koma-mini-stack: 0.54em;
  }
}

@container (max-width: 26px) {
  .mini-square .piece {
    --koma-mini-glyph: 94cqmin;
    --koma-mini-glyph-gold: 91cqmin;
    --koma-mini-glyph-knight: 90cqmin;
    --koma-mini-glyph-major: 91cqmin;
    --koma-mini-stack: 0.50em;
  }
}

.catalog-mini .piece.sente,
.app.view-swapped .catalog-mini .piece.sente,
.catalog-mini .piece.sente.promoted,
.app.view-swapped .catalog-mini .piece.sente.promoted {
  transform: none;
  color: #800020;
  opacity: 1;
}

.catalog-mini .piece.gote,
.app.view-swapped .catalog-mini .piece.gote,
.catalog-mini .piece.gote.promoted,
.app.view-swapped .catalog-mini .piece.gote.promoted {
  transform: rotate(180deg);
  color: #173C75;
  opacity: 1;
}

.mini-hands {
  flex: 0 0 auto;
  min-height: 1.55em;
  max-height: 2.8em;
  overflow: hidden;
  font-size: 0.72rem;
  color: #2b1a0e;
  text-align: center;
  font-weight: 800;
  line-height: 1.25;
  padding: 2px 0;
}

.mini-turn {
  flex: 0 0 auto;
  margin: 4px 0 0;
  font-size: 0.82rem;
  text-align: center;
  color: #111111 !important;
  font-weight: 800;
  -webkit-text-stroke: 0 !important;
  text-shadow: none !important;
}

.mini-turn-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 2px 4px;
  margin: 4px 0 0;
  min-width: 0;
  width: 100%;
}

.mini-turn-row .mini-turn {
  flex: 1 1 auto;
  margin: 0;
  min-width: 0;
}

.mini-kifu-nav {
  /* ② ≪ ＜ ＞ ≫ の4ボタン。幅はミニ盤面の幅から手番表示分を引いて4等分（同じ大きさ）。
     高さは従来の2ボタン時と同じ式にして、カードの高さを変えない。 */
  --mini-kifu-btn-w: clamp(16px, calc((100cqw - 2.7rem - 12px) / 4), 36px);
  --mini-kifu-btn-h: clamp(24px, calc(50cqw - 6px), 36px);
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  margin-left: auto;
  max-width: 100%;
}

.mini-turn-row.has-kifu-nav {
  flex-wrap: wrap;
  justify-content: space-between;
}

.mini-turn-row.has-kifu-nav .mini-turn {
  flex: 1 1 auto;
  text-align: left;
  white-space: nowrap;
  padding-left: 2px;
}

.mini-kifu-btn,
.catalog-dialog .mini-kifu-btn {
  box-sizing: border-box;
  flex: 0 0 auto;
  width: var(--mini-kifu-btn-w);
  height: var(--mini-kifu-btn-h);
  min-width: 16px;
  min-height: 24px;
  padding: 0;
  margin: 0;
  border-radius: 8px;
  font-size: min(0.92rem, calc(var(--mini-kifu-btn-w) * 0.62));
  line-height: 1;
  font-weight: 800;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* とても狭いミニ盤面（従来も2ボタンが手番表示の下へ折り返していた幅）では、
   ボタン列を1行使って4等分し、押しやすさを保つ。高さは従来の折り返し時と同じ。 */
@container (max-width: 117px) {
  .mini-turn-row.has-kifu-nav .mini-turn {
    flex-basis: 100%;
  }

  .mini-turn-row.has-kifu-nav .mini-kifu-nav {
    --mini-kifu-btn-w: clamp(16px, calc((100cqw - 6px) / 4), 36px);
    flex-basis: 100%;
  }
}

.catalog-meta {
  margin: 2px 0 0;
  font-size: 0.82rem;
  text-align: center;
  color: var(--text-on-light-muted);
  font-weight: 700;
  white-space: pre-line;
}

.catalog-card-title.is-editable {
  cursor: pointer;
  border-radius: 4px;
}

.catalog-card-title.is-editable:hover,
.catalog-card-title.is-editable:focus {
  text-decoration: underline;
  outline: none;
}

.catalog-card-cats {
  display: block;
}

.catalog-card-cats.is-editable {
  cursor: pointer;
  border-radius: 4px;
}

.catalog-card-cats.is-editable:hover,
.catalog-card-cats.is-editable:focus {
  text-decoration: underline;
  outline: none;
}

#catalogCategoryEditModal .category-picker {
  margin-bottom: 8px;
}

.catalog-meta.catalog-meta-editing {
  white-space: normal;
}

.catalog-title-edit {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 4px;
  width: 100%;
  box-sizing: border-box;
}

.catalog-title-edit input {
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 2px 4px;
  font: inherit;
  font-weight: 700;
  text-align: center;
  color: inherit;
  background: #fffdf8;
  border: 1px solid #c8b496;
  border-radius: 4px;
}

.catalog-title-edit-actions {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.catalog-title-edit-actions button {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.76rem;
  padding: 4px 6px;
}

#netWaitSideStep .catalog-mini,
#netWaitingSelfStep .catalog-mini,
#netWaitDock .catalog-mini {
  width: min(196px, 70vw);
  max-width: 196px;
  margin-inline: auto;
}

.catalog-wait-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.catalog-wait-row .catalog-wait-btn {
  flex: 1 1 4.8em;
  min-width: 0;
  font-size: 0.76rem;
  padding: 6px 4px;
  white-space: nowrap;
}

.catalog-wait-btn.is-waiting,
.catalog-dialog .catalog-wait-btn.is-waiting:not(.catalog-mini),
.catalog-dialog .catalog-wait-btn.is-waiting:not(.catalog-mini):hover {
  background: #c4451a;
  color: #fff8e8;
  border-color: #8a2208;
}

.catalog-net-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 8px 0 10px;
  font-size: 0.86rem;
}

.catalog-realtime-status {
  flex: 1 1 12em;
  color: #5a4634;
}

.catalog-waiters {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 6px;
}

.catalog-waiters.is-empty {
  display: none;
}

.catalog-waiter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  background: #fff6e8;
  border: 1px solid #d8c4a4;
  border-radius: 8px;
}

.catalog-waiter-info {
  flex: 1 1 10em;
  margin: 0;
  font-size: 0.78rem;
  line-height: 1.35;
}

.catalog-waiter-challenge {
  flex: 0 0 auto;
  font-size: 0.76rem;
  padding: 5px 8px;
}

.catalog-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}

.catalog-actions button {
  flex: 1;
  min-width: 0;
  font-size: 0.8rem;
  padding: 6px 4px;
  white-space: nowrap;
}

.catalog-empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--text-on-light);
  font-weight: 700;
}

.catalog-community-bar {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 10px;
}

.catalog-community-bar.hidden {
  display: none;
}

.catalog-auth-row,
.catalog-community-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.catalog-auth-status {
  color: var(--text-on-light);
  font-weight: 700;
  font-size: 0.82rem;
}

.catalog-community-tools input[type="search"] {
  flex: 1 1 12rem;
  min-width: 8rem;
  padding: 6px 8px;
  border-radius: 8px;
  border: 1px solid #5a3214;
  background: #fff8e8;
  color: #2b1a0e;
}

#catalogCommunityMore {
  margin: 8px auto 0;
  display: block;
}

#positionSaveModal {
  align-items: flex-start;
  justify-content: center;
  padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  overflow: auto;
}

#positionSaveModal .modal-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
  min-width: 0;
  width: min(calc(100vw - 16px), 520px);
  max-width: calc(100vw - 16px);
  max-height: min(92dvh, calc(100dvh - 16px));
  overflow: auto;
  box-sizing: border-box;
}

#positionSaveModal .modal-actions {
  flex-wrap: wrap;
  justify-content: stretch;
}

#positionSaveModal .modal-actions button {
  writing-mode: horizontal-tb;
  white-space: nowrap;
}

#positionSaveCategories {
  width: 100%;
}

#positionSaveModal .modal-card,
#positionSaveModal .category-picker,
#positionSaveModal .category-picker-group,
#positionSaveModal .category-picker-group label,
#positionSaveModal .category-picker-child {
  color: #2b1a0e;
}

#positionSaveModal .category-picker-group {
  background: #efe4c8;
}

#positionSaveModal .category-picker-group label,
#positionSaveModal .category-picker-child {
  font-weight: 800;
}

@media (max-width: 720px) {
  .catalog-filters > summary {
    display: block;
  }

  #positionSaveModal .modal-actions {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }

  #positionSaveModal .modal-actions button {
    flex: 1 1 auto;
    width: 100%;
    min-height: 44px;
    writing-mode: horizontal-tb;
    white-space: nowrap;
  }

  html,
  body {
    height: 100dvh;
    max-width: 100%;
    overflow-x: hidden;
  }

  body {
    min-height: 100dvh;
  }

  .app,
  .app:not(.editing),
  .app.editing,
  .app.kifu-open:not(.editing),
  .app.view-swapped:not(.editing),
  .app.kifu-open.view-swapped:not(.editing) {
    max-width: 100%;
    height: auto;
    min-height: 100dvh;
    max-height: none;
    margin: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding-top: max(2px, env(safe-area-inset-top));
    padding-bottom: max(2px, env(safe-area-inset-bottom));
    padding-left: env(safe-area-inset-left) !important;
    padding-right: env(safe-area-inset-right) !important;
  }

  .app:has(#netWaitDock:not(.hidden)) {
    height: auto;
    max-height: none;
    overflow-y: auto;
  }

  .app.editing {
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
  }

  .app.editing .table {
    flex: 0 0 auto;
    min-height: 0;
  }

  .app.editing .board-wrap {
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
    height: auto;
    max-height: none;
    overflow: visible;
    container-type: normal;
  }

  .app.editing .board-chrome {
    --board-size: 100%;
    width: 100%;
    height: auto;
    aspect-ratio: 1 / var(--sq-aspect);
    max-width: 100%;
  }

  .header h1 {
    font-size: clamp(1.35rem, 6vw, 1.8rem);
  }

  .subtitle {
    font-size: 0.82rem;
    padding: 0 8px;
  }

  .table {
    position: relative;
    width: 100%;
    max-width: 100%;
    flex: 0 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
  }

  .editor-bench,
  .app.editing .editor-bench,
  .app.editing.view-swapped .editor-bench {
    position: static !important;
    transform: none !important;
    top: auto !important;
    right: auto !important;
    left: auto !important;
    bottom: auto !important;
    width: 100% !important;
    height: auto !important;
    max-height: none !important;
    margin: 0;
    order: 4;
    padding: 2px 4px 4px;
    overflow-x: auto;
    overflow-y: hidden;
    flex: 0 0 auto;
    z-index: auto;
  }

  .app.editing .editor-bench,
  .app.editing.view-swapped .editor-bench {
    display: flex;
    flex-direction: column;
  }

  .app.editing .gote-area,
  .app.editing.view-swapped .gote-area {
    order: 1;
  }

  .app.editing .board-wrap,
  .app.editing.view-swapped .board-wrap {
    order: 2;
  }

  .app.editing .sente-area,
  .app.editing.view-swapped .sente-area {
    order: 3;
  }

  .app.editing .editor-bench-head {
    margin-bottom: 2px;
    font-size: 0.72rem;
    text-align: left;
    flex: 0 0 auto;
  }

  .app.editing .editor-bench-pieces,
  .editor-bench-pieces {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    overflow-x: auto;
    overflow-y: hidden;
    align-items: center;
    align-content: center;
    gap: 4px;
    min-height: 36px;
    max-height: none;
    flex: 0 0 auto;
    width: 100%;
    grid-template-columns: none;
  }

  .app.editing .editor-bench-piece {
    flex: 0 0 auto;
    width: 38px;
    min-width: 38px;
  }

  .app.editing .kifu-side-status,
  .app.editing .kifu-side-opening,
  .app.editing .kifu-show-button,
  .app.editing .kifu-dock > .onijin-button {
    display: none;
  }

  .app.editing {
    padding-top: max(2px, env(safe-area-inset-top));
  }

  .gote-area,
  .sente-area,
  .app.view-swapped .gote-area,
  .app.view-swapped .sente-area,
  .app.editing .gote-area,
  .app.editing .sente-area,
  .app.kifu-open:not(.editing) .sente-area {
    position: static;
    transform: none;
    top: auto;
    right: auto;
    left: auto;
    bottom: auto;
    width: 100%;
    height: auto;
    min-height: 0;
    overflow: visible;
    flex: 0 0 auto;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
    padding: 1px 2px;
    border-radius: 8px;
    order: 0;
  }

  .gote-area,
  .app.view-swapped .gote-area,
  .app.editing .gote-area,
  .app.editing.view-swapped .gote-area {
    order: 1;
    padding-right: 4px;
  }

  .board-wrap,
  .app.view-swapped .board-wrap {
    order: 2;
  }

  .sente-area,
  .app.view-swapped .sente-area,
  .app.kifu-open:not(.editing) .sente-area,
  .app.editing .sente-area,
  .app.editing.view-swapped .sente-area {
    order: 3;
  }

  .player-head {
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    min-width: 0;
    order: 2;
  }

  .sente-main {
    width: 100%;
    flex: 1 1 auto;
    flex-basis: auto;
    min-width: 0;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 2px;
  }

  .sente-main .board-side-tools {
    order: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    max-width: 100%;
    margin: 0;
    padding: 0;
  }

  .sente-main .player-head {
    order: 2;
    flex: 0 0 auto;
  }

  .sente-main .hand,
  .gote-area .hand,
  .sente-area .hand {
    flex: 1 1 100%;
    width: 100%;
    min-width: 0;
    max-width: 100%;
    height: auto;
    min-height: 2.4rem;
    max-height: none;
    margin: 0;
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start;
    align-content: flex-start;
    align-items: center;
    overflow: visible;
    gap: 2px;
    order: 3;
  }

  .app.editing .sente-main {
    flex-wrap: nowrap;
    align-items: flex-start;
    gap: 4px;
  }

  .app.editing .sente-main .hand,
  .app.editing .gote-area .hand,
  .app.editing .sente-area .hand {
    flex: 1 1 auto;
    width: auto;
    min-height: 0;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    flex-direction: row;
    flex-wrap: nowrap;
    align-items: flex-start;
    justify-content: flex-start;
    gap: 2px;
    order: 1;
  }

  .app.editing .sente-main .board-side-tools {
    order: 2;
    margin-left: auto;
    flex: 0 0 auto;
  }

  .app.editing .sente-main .player-head {
    display: none;
  }

  .app.editing .hand-edit {
    flex-direction: column-reverse;
    flex: 0 0 auto;
    gap: 0;
    margin: 0;
    width: auto;
  }

  .hand-piece {
    width: clamp(22px, 7.2vw, 32px);
    height: clamp(26px, 8.4vw, 38px);
  }

  .hand-piece .piece {
    font-size: calc(clamp(0.62rem, 3.2vw, 0.88rem) * var(--koma-glyph));
  }

  .hand-empty.ui-pill,
  .ui-pill {
    padding: 3px 7px;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
  }

  .player-badge {
    padding: 3px 7px;
    font-size: 0.68rem;
    letter-spacing: 0.04em;
  }

  .turn-hint,
  .net-clock {
    margin: 0;
    font-size: 0.68rem;
  }

  .board-wrap {
    position: relative;
    flex: 0 0 auto;
    min-height: 0;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 0;
    overflow: visible;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    container-type: normal;
  }

  .board-side-tools {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: flex-start;
    gap: 4px;
    width: auto;
    max-width: 100%;
    margin: 0;
    flex: 0 0 auto;
    z-index: 3;
  }

  .history-btns {
    display: flex;
    gap: 4px;
  }

  .history-btn {
    width: 32px;
    min-width: 32px;
    height: 30px;
    padding: 0;
    font-size: 1rem;
    line-height: 1;
  }

  .app.editing .editor-rclick-toggle {
    margin: 0;
  }

  .board-chrome {
    --board-size: 100%;
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    aspect-ratio: 1 / var(--sq-aspect);
  }

  .file-labels,
  .rank-labels {
    display: none !important;
  }

  .board-stack {
    grid-column: auto;
    grid-row: auto;
    width: 100%;
    height: 100%;
  }

  .board {
    border-width: 4px;
    box-shadow: inset 0 0 0 1px var(--board-inset), 0 6px 16px rgba(0, 0, 0, 0.35);
  }

  .file-labels,
  .rank-labels {
    display: none !important;
  }

  .board .square {
    container-type: size;
  }

  .board .piece {
    font-size: calc(68cqmin * var(--koma-glyph));
    line-height: 1;
  }

  .board .piece-glyph {
    font-size: 1em;
  }

  .board .piece-stack-top,
  .board .piece-stack-bottom {
    font-size: 0.48em;
  }

  .board-wrap > .onijin-button {
    position: absolute;
    top: 0;
    right: 0;
    z-index: 9;
    margin: 0;
    min-width: 3.8rem;
    padding: 5px 8px;
    font-size: 0.72rem;
  }

  .kifu-dock {
    position: relative;
    top: auto;
    z-index: 4;
    order: -1;
    transform: none;
    right: auto;
    left: auto;
    width: 100%;
    height: auto;
    min-height: 0;
    flex: 0 0 auto;
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-template-rows: auto auto auto;
    align-items: stretch;
    gap: 4px;
    pointer-events: auto;
    padding: 4px 4px 2px;
    background: rgba(8, 7, 14, 0.88);
  }

  .kifu-dock.kifu-open {
    z-index: 4;
  }

  .app.editing .kifu-dock {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    grid-template-rows: auto auto;
  }

  .app.editing .kifu-dock #homeLoginButton,
  .app.editing .kifu-dock #homeLogoutButton {
    grid-column: 1;
    grid-row: 1;
  }

  .app.editing .kifu-dock #settingsButton {
    grid-column: 2;
    grid-row: 1;
  }

  .app.editing .kifu-dock #bgmFab {
    grid-column: 1;
    grid-row: 2;
  }

  .app.editing .kifu-dock .home-auth-status {
    grid-column: 2;
    grid-row: 2;
  }

  .kifu-side-status {
    grid-column: 2 / -1;
    grid-row: 2;
    text-align: left;
    font-size: 0.72rem;
    line-height: 1.2;
    align-self: center;
  }

  .kifu-side-opening {
    grid-column: 2 / -1;
    grid-row: 3;
    text-align: left;
    font-size: 0.64rem;
    line-height: 1.25;
    align-self: center;
  }

  .kifu-show-button {
    grid-column: 3;
    grid-row: 1;
    writing-mode: horizontal-tb;
    flex: 0 0 auto;
    align-self: stretch;
    min-width: 0;
    max-width: none;
    width: 100%;
    height: 36px;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 0.78rem;
    line-height: 1.1;
    white-space: nowrap;
  }

  .kifu-dock > .onijin-button {
    position: static;
    grid-column: 4;
    grid-row: 1;
    z-index: auto;
    top: auto;
    right: auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    height: 36px;
    min-height: 36px;
    margin: 0;
    padding: 6px 4px;
    font-size: 0.78rem;
    line-height: 1.1;
    white-space: nowrap;
    transform: none;
  }

  .kifu-panel {
    position: fixed;
    z-index: 40;
    left: max(8px, env(safe-area-inset-left));
    right: max(8px, env(safe-area-inset-right));
    top: calc(108px + env(safe-area-inset-top));
    bottom: max(8px, env(safe-area-inset-bottom));
    width: auto;
    height: auto;
    max-height: none;
    visibility: hidden;
    pointer-events: none;
    opacity: 0;
    transform: translateY(12px);
  }

  .kifu-panel.hidden {
    display: flex !important;
    visibility: hidden;
    pointer-events: none;
  }

  .kifu-panel.is-overlay-open {
    visibility: visible;
    pointer-events: auto;
    opacity: 1;
    transform: none;
    background: rgba(18, 14, 24, 0.94);
  }

  .kifu-item {
    font-size: 0.78rem;
    padding: 6px 8px;
    white-space: nowrap;
  }

  .kifu-backdrop:not(.hidden) {
    display: block;
    position: fixed;
    inset: 0;
    z-index: 35;
    background: rgba(8, 6, 12, 0.55);
  }

  .controls {
    flex: 0 0 auto;
    margin-top: 0;
    padding-bottom: 0.15rem;
  }

  .app.editing .editor-quick-bar {
    gap: 4px;
  }

  .app.editing .editor-quick-bar button {
    padding: 4px 8px;
    font-size: 0.78rem;
  }

  .app.editing .editor-quick-bar button.editor-rclick-toggle {
    font-size: 0.68rem;
    padding: 3px 6px;
    min-height: 0;
    width: auto;
    max-width: max-content;
  }

  .control-buttons {
    gap: 2px;
  }

  .control-row-start,
  .control-row-end,
  .control-row-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 2px;
    align-items: stretch;
  }

  .control-row-end {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .control-row-tools {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  #resignButton,
  .resign-btn {
    order: 99;
    margin-left: 0;
    grid-column: 1 / -1;
    justify-self: end;
    width: auto;
    min-width: 5.5rem;
    max-width: min(8.5rem, 100%);
    margin-top: 16px;
  }

  .app.net-play #resignButton {
    grid-column: 1 / -1;
    justify-self: end;
    width: auto;
    min-width: 5.5rem;
    max-width: min(8.5rem, 100%);
    margin-top: 0;
  }

  .control-row-seats {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) minmax(0, 1.35fr);
    gap: 2px;
    align-items: stretch;
  }

  .control-row-start .net-play-entry {
    display: contents;
  }

  .control-row-start .net-count-wrap {
    grid-column: 1 / -1;
    justify-content: center;
    gap: 2px 16px;
    padding: 2px 4px 1px;
  }

  .net-presence-count,
  .net-wait-count {
    font-size: 0.62rem;
    line-height: 1.2;
    text-align: center;
  }

  .position-label {
    gap: 2px;
    min-width: 0;
    font-size: 0.72rem;
  }

  .position-label .ui-pill {
    padding: 3px 6px;
    font-size: 0.64rem;
  }

  .position-label select,
  .position-label .seat-toggle,
  .seat-toggle {
    min-width: 0;
    flex: 1 1 auto;
    padding: 6px 8px;
    font-size: 0.72rem;
  }

  .ai-think-label {
    grid-column: auto;
  }

  .control-row-start button,
  .control-row-end button,
  .control-row-tools button,
  .control-buttons button,
  .controls button {
    min-width: 0;
    width: 100%;
    min-height: 32px;
    padding: 5px 3px;
    font-size: 0.66rem;
    line-height: 1.2;
    white-space: normal;
  }

  .app.net-play .control-row-end #resignButton {
    width: auto;
    min-width: 5.5rem;
    max-width: min(8.5rem, 100%);
    justify-self: end;
    grid-column: 1 / -1;
    margin-top: 0;
  }

  .kifu-dock > .bgm-dock,
  .kifu-dock > .bgm-dock .home-auth-dock {
    display: contents;
  }

  .kifu-dock #homeLoginButton,
  .kifu-dock #homeLogoutButton {
    grid-column: 1;
    grid-row: 1;
  }

  .kifu-dock #settingsButton {
    grid-column: 2;
    grid-row: 1;
  }

  .kifu-dock #bgmFab {
    grid-column: 1;
    grid-row: 2;
  }

  .kifu-dock .home-auth-status {
    grid-column: 1;
    grid-row: 3;
    max-width: none;
    text-align: left;
    font-size: 0.68rem;
    align-self: center;
  }

  .kifu-dock .bgm-fab {
    position: static;
    min-width: 0;
    width: 100%;
    height: 36px;
    min-height: 36px;
    padding: 6px 4px;
    font-size: 0.78rem;
    line-height: 1.1;
  }

  .kifu-dock .bgm-panel {
    position: absolute;
    left: 4px;
    right: auto;
    top: calc(100% + 4px);
    bottom: auto;
    z-index: 40;
  }

  .bgm-dock {
    right: auto;
    bottom: auto;
    gap: 4px;
  }

  .bgm-fab {
    min-width: 2.8em;
    padding: 6px 10px;
    font-size: 0.72rem;
  }

  .modal {
    padding: max(8px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
    align-items: flex-start;
    overflow: auto;
  }

  .modal-card {
    min-width: 0;
    width: min(96vw, 520px);
    max-height: min(92dvh, 900px);
    overflow: auto;
  }

  .settings-card {
    max-height: min(88dvh, 720px);
    overflow: auto;
  }

  .settings-pair {
    flex-wrap: wrap;
  }

  .catalog-modal {
    padding: 0;
    align-items: stretch;
  }

  .catalog-dialog {
    min-width: 0;
    width: 100%;
    max-width: none;
    height: 100dvh;
    max-height: 100dvh;
    padding: 8px 6px max(8px, env(safe-area-inset-bottom));
  }

  .catalog-dialog[data-cols="2"] {
    padding-left: 2px;
    padding-right: 2px;
  }

  .clock-float-card {
    left: 8px;
    top: max(12px, env(safe-area-inset-top));
    width: min(320px, calc(100vw - 16px));
  }
}

@media (max-width: 720px) {
  .app.editing .hand-edit {
    flex-direction: column-reverse;
    gap: 0;
  }

  .app.editing .hand-edit-btn {
    width: 28px;
    min-width: 28px;
    height: 22px;
  }
}

@media (max-width: 480px) {
  .app.editing,
  .app.editing.view-swapped {
    padding-left: max(6px, env(safe-area-inset-left));
    padding-right: max(6px, env(safe-area-inset-right));
  }

  .file-labels,
  .rank-labels {
    display: none !important;
  }
}

@media (min-width: 721px) {
  .catalog-filters > summary {
    display: none;
  }

  .catalog-filters:not([open]) .catalog-filters-body {
    display: block;
  }

  #kifuClose {
    width: 32px;
    min-width: 32px;
    height: 32px;
    padding: 0;
    line-height: 1;
  }
}

@media (max-width: 320px) {
  .catalog-actions button,
  .catalog-wait-btn {
    font-size: 0.78rem;
  }
}

@media (max-width: 720px) and (orientation: landscape) and (max-height: 500px) {
  .board-chrome,
  .app.editing .board-chrome {
    --board-size: min(100%, calc(100dvh - 12rem));
    width: var(--board-size);
    max-width: var(--board-size);
    margin-inline: auto;
  }
}

@media (max-width: 720px) and (max-height: 700px) {
  .controls {
    padding-bottom: 0.25rem;
  }

  .control-row-start button,
  .control-row-end button,
  .control-row-tools button,
  .control-buttons button,
  .controls button {
    min-height: 30px;
    padding: 3px 2px;
    font-size: 0.62rem;
  }
}

.bgm-dock {
  position: fixed;
  right: max(10px, env(safe-area-inset-right));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 10050;
  display: flex;
  flex-direction: column-reverse;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
}

.bgm-fab,
.bgm-panel,
.home-auth-dock {
  pointer-events: auto;
}

.home-auth-dock {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
  max-width: 9.5rem;
}

.home-auth-status {
  color: #fff4c2;
  font-size: 0.72rem;
  font-weight: 800;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
  text-align: right;
  line-height: 1.2;
}

.home-auth-dock .bgm-fab {
  min-width: 0;
  padding: 6px 10px;
  font-size: 0.78rem;
}

.home-fav-set-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  margin: 0 0 10px;
}

.home-fav-set-bar.hidden {
  display: none;
}

.home-fav-set-btn {
  min-height: 2.4rem;
  padding: 8px 12px;
  font-weight: 800;
}

.home-fav-set-btn.is-waiting {
  background: #c4451a;
  color: #fff8e8;
}

.home-fav-set-btn.is-pending {
  background: #d98a3a;
  color: #fff8e8;
}

.home-fav-set-btn.is-error {
  background: #7a2d2d;
  color: #fff8e8;
}

.catalog-fav-edit-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  margin: 0 0 8px;
  padding: 8px 10px;
  background: #fff3e4;
  border: 1px solid #d8b48a;
  border-radius: 10px;
}

.catalog-fav-edit-bar.hidden {
  display: none;
}

.catalog-fav-edit-label {
  flex: 1 1 12em;
  margin: 0;
  font-weight: 800;
  font-size: 0.92rem;
}

.catalog-fav-edit-save {
  font-size: 0.8rem;
  color: #5a4634;
}

.catalog-fav-edit-save.is-error {
  color: #a31d12;
  font-weight: 800;
}

.catalog-fav-clock {
  margin: 4px 0 0;
  font-size: 0.76rem;
  line-height: 1.35;
  color: #5a4634;
}

.catalog-fav-edit {
  min-width: 0;
  width: 100%;
  margin-top: 4px;
}

.catalog-dialog.is-fav-set-editing .catalog-virtual-window > .catalog-card-item {
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: visible;
}

.catalog-fav-cond {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  margin-top: 4px;
  padding: 5px 6px;
  background: #fffaf2;
  border: 1px solid #d8b48a;
  border-radius: 8px;
}

.catalog-fav-cond-empty {
  background: #f7f1e6;
  border-style: dashed;
}

.catalog-fav-cond.is-just-added {
  background: #ffe4c8;
  border-color: #c4451a;
  box-shadow: 0 0 0 2px rgba(196, 69, 26, 0.28);
}

.catalog-fav-cond-hint {
  margin: 0;
  font-size: 0.72rem;
  color: #5a4634;
}

.catalog-fav-cond-sides {
  display: flex;
  gap: 3px;
  min-width: 0;
}

.catalog-fav-cond-side {
  flex: 1 1 0;
  min-width: 0;
  font-size: 0.7rem;
  padding: 4px 2px;
}

.catalog-fav-cond-meta {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
}

.catalog-fav-cond-clock {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 0.7rem;
  line-height: 1.25;
  color: #5a4634;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  line-clamp: 2;
  word-break: break-word;
}

.catalog-fav-cond-btn {
  flex: 0 0 auto;
  font-size: 0.68rem;
  padding: 3px 6px;
  white-space: nowrap;
}

.catalog-fav-edit-actions,
.catalog-fav-extra-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.catalog-fav-extra-row {
  align-items: center;
  font-size: 0.76rem;
}

.catalog-dialog.is-fav-set-editing .catalog-waiters {
  display: none;
}

.fav-set-clock-picker {
  position: fixed;
  z-index: 10240;
  width: min(280px, calc(100vw - 16px));
  max-height: min(70dvh, 420px);
  overflow: auto;
  padding: 8px;
  background: #fffaf2;
  border: 1px solid #c9a06a;
  border-radius: 10px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.28);
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.fav-set-clock-picker.hidden,
.fav-set-clock-picker[hidden] {
  display: none;
}

.fav-set-clock-picker-title {
  margin: 0;
  font-size: 0.8rem;
  font-weight: 800;
}

.fav-set-dialog {
  width: min(720px, calc(100vw - 16px));
  height: auto;
  max-height: min(92dvh, 900px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-align: left;
}

.fav-set-help {
  margin: 0 0 8px;
  font-size: 0.82rem;
  line-height: 1.45;
  flex: 0 0 auto;
}

.fav-set-create-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 8px;
  flex: 0 0 auto;
}

.fav-set-create-row input {
  flex: 1 1 12rem;
  min-width: 0;
}

.fav-set-save-status {
  min-height: 1.2em;
  margin: 0 0 8px;
  font-size: 0.85rem;
  font-weight: 700;
  color: #5a4634;
}

.fav-set-save-status.is-error {
  color: #8b1e1e;
}

.fav-set-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 0 0 8px;
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.fav-set-editor {
  display: flex;
  flex-direction: column;
  min-height: 0;
  flex: 1 1 auto;
}

.fav-set-editor.hidden {
  display: none;
}

.fav-set-item-list {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow: auto;
}

.fav-set-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.fav-set-wait-error {
  flex: 1 0 100%;
  margin: 0;
  color: #b42318;
  font-size: 0.8rem;
}

.fav-set-item-head,
.fav-set-item-row {
  display: grid;
  grid-template-columns: 1.5rem minmax(7rem, 1.4fr) 5.2rem minmax(8rem, 1.6fr) auto;
  gap: 6px;
  align-items: center;
}

.fav-set-item-head {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 4px 0;
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--text-on-light);
  background: var(--surface-light);
}

.fav-set-name-input {
  flex: 1 1 10rem;
  min-width: 8rem;
  font-weight: 700;
}

.fav-set-count {
  font-size: 0.8rem;
  color: #5a4634;
  font-weight: 700;
}

.fav-set-name,
.fav-set-item-meta {
  min-width: 0;
  text-align: left;
  margin: 0;
  font-size: 0.86rem;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fav-set-editor-head,
.fav-set-editor-tools,
.fav-set-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  margin: 0 0 8px;
  flex: 0 0 auto;
}

.fav-set-item-row select {
  width: 100%;
  min-width: 0;
  max-width: none;
}

@media (max-width: 640px) {
  .fav-set-dialog {
    width: 100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 0;
  }

  .fav-set-item-head {
    display: none;
  }

  .fav-set-item-row {
    grid-template-columns: auto 1fr auto;
    grid-template-areas:
      "check name remove"
      "check side clock";
  }

  .fav-set-item-row input[type="checkbox"] {
    grid-area: check;
  }

  .fav-set-item-meta {
    grid-area: name;
    white-space: normal;
  }

  .fav-set-item-row .fav-set-side {
    grid-area: side;
  }

  .fav-set-item-row .fav-set-clock {
    grid-area: clock;
  }

  .fav-set-item-row .fav-set-remove {
    grid-area: remove;
  }
}

.bgm-fab {
  min-width: 3.2em;
  padding: 8px 14px;
  font-size: 0.86rem;
  border: 2px solid #c4451a;
  box-shadow: 0 0 0 1px #f3dcb0, 0 6px 12px rgba(0, 0, 0, 0.35);
}

.bgm-panel {
  width: min(280px, calc(100vw - 24px));
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--surface-light);
  color: var(--text-on-light);
  border: 1px solid var(--control-border);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  text-align: left;
}

.bgm-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  cursor: grab;
  touch-action: none;
}

.bgm-panel-title {
  font-size: 0.9rem;
  font-weight: 800;
  flex: 1;
}

.bgm-panel-head button {
  padding: 4px 8px;
  font-size: 0.75rem;
  min-width: 0;
}

.bgm-panel-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0;
  font-size: 0.82rem;
  font-weight: 700;
}

.bgm-panel-row select,
.bgm-panel-row input[type="range"] {
  flex: 1;
  min-width: 0;
}

.bgm-seek-row {
  margin-bottom: 2px;
}

.bgm-seek-meta {
  justify-content: space-between;
  gap: 6px;
}

.bgm-seek-time {
  min-width: 6.4em;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.bgm-seek-meta button {
  padding: 4px 8px;
  font-size: 0.75rem;
  min-width: 0;
}

.bgm-toggle {
  min-width: 4.6em;
  min-height: 40px;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 0.88rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  cursor: pointer;
  border: 1px solid var(--btn-border);
}

.bgm-toggle.is-on {
  background: var(--clock-pick-on-bg);
  color: var(--clock-pick-on-ink);
  box-shadow: inset 0 0 0 1px var(--clock-pick-on-ring);
}

.bgm-toggle.is-off {
  background: var(--btn-secondary);
  color: var(--text-on-light);
  opacity: 0.92;
}
