/* 局面共通：盤面・持ち駒・対局者情報・着手演出・結果表示
 * 読み込み順：base.css → 局面を扱う画面では board.css → カテゴリ.css
 * 条件付き指定は直前の通常指定と併せて確認する。ファイル追加は事前承認制。
 */

.matchContent {
  padding: 12px;
}

.gameArea {
  margin: 0px;
  position: relative;
}

.gameToolbar {
  display: flex;
  align-items: center;
  padding: 0px 0px 10px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 12px;
  font-weight: 700;
}

.gameToolbar small {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 2px;
}

.gameToolbar button {
  display: inline-block;
  padding: 8px 18px;
  text-decoration: none;
}
.gameToolbar button:where(:not(.uiAction)){
  border: 1px solid var(--control-edge);
  border-radius: 0px;
  background: linear-gradient(var(--control-surface), var(--control-surface));
  color: var(--control-ink);
}
.gameToolbar button:not(:disabled):hover:where(:not(.uiAction)){
  border-color: rgb(140, 184, 144);
  background: var(--control-hover);
}
.gameToolbar button:disabled:where(:not(.uiAction)){
  opacity: 0.4;
}

.boardLayout {
  display: grid;
  grid-template-columns: 54px minmax(0px, 1fr) 54px 210px;
  gap: 8px;
  align-items: start;
}

.boardFrame {
  padding: 8px;
  border: 1px solid var(--control-edge);
  background: linear-gradient(135deg, rgb(235, 198, 127), rgb(235, 198, 127));
  box-shadow: rgba(82, 99, 75, 0.15) 0px 0px 0px 3px inset;
}

.board {
  display: grid;
  grid-template-columns: repeat(9, minmax(0px, 1fr));
}

.square {
  border: 0px;
  border-radius: 0px;
  padding: 0px;
  min-width: 0px;
}

.square img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.flip {
  transform: rotate(180deg);
}

.handRail {
  border: 1px solid var(--control-edge);
  background: linear-gradient(90deg, rgb(196, 154, 99), rgb(196, 154, 99));
  padding: 4px;
  min-width: 0px;
}

.railLabel {
  display: block;
  color: rgb(32, 37, 31);
  font-size: 9px;
  text-align: center;
  white-space: nowrap;
  margin: 2px 0px 5px;
}

.hand {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0px;
}

.handPiece {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  min-width: 0px;
  min-height: 46px;
  padding: 1px;
  border: 1px solid rgb(83, 99, 88);
  background: transparent;
  color: rgb(36, 31, 23);
  font-size: 12px;
  font-weight: 700;
  border-radius: 0px;
}

.handPiece img {
  width: 30px;
  height: 30px;
  object-fit: contain;
  pointer-events: none;
}

.handPiece span {
  padding: 0px 2px;
}

.ownHand {
  align-self: end;
}

.gameInfo {
  display: grid;
  gap: 9px;
  min-width: 0px;
}

.playerBar {
  min-width: 0px;
  padding: 13px 12px;
  border-width: 1px 1px 1px 3px;
  border-style: solid;
  border-color: var(--control-edge);
  border-image: none;
  background: linear-gradient(115deg, rgb(255, 255, 255), rgb(255, 255, 255));
}

.playerBar.self {
  border-left-color: var(--green);
  background: linear-gradient(115deg, rgb(238, 244, 231), rgb(238, 244, 231));
}

.playerBar > span {
  display: block;
  overflow-wrap: anywhere;
}

.playerBar > span:not(.eyebrow) {
  font-weight: 700;
}

.timeLine {
  display: flex;
  gap: 7px;
  align-items: baseline;
  color: rgb(32, 37, 31);
  font-size: 12px;
  margin-top: 5px;
}

.clock {
  font-size: 34px;
  line-height: 1.3;
  color: rgb(32, 37, 31);
  font-variant-numeric: tabular-nums;
}

.clock.lowTime {
  color: rgb(181, 43, 40);
}

.gameMessage {
  min-height: 130px;
  border: 1px solid var(--control-edge);
  background: rgb(255, 255, 239);
  padding: 14px 12px;
  font-size: 14px;
}

.gameMessage p {
  margin: 0px;
}

.gameMessage p + p:not(:empty) {
  margin-top: 12px;
  color: rgb(32, 37, 31);
}

.promotion p {
  margin: 0px;
}

@media (min-width: 1600px) {
  .boardLayout {
    grid-template-columns: 64px minmax(0px, 1fr) 64px 240px;
}

  .handPiece {
    min-height: 52px;
}

  .handPiece img {
    width: 36px;
    height: 36px;
}
}

@media (max-width: 1200px) {
  .boardLayout {
    grid-template-columns: 46px minmax(0px, 1fr) 46px 180px;
    gap: 6px;
}

  .handRail {
    padding: 2px;
}

  .handPiece {
    min-height: 39px;
}

  .handPiece img {
    width: 26px;
    height: 26px;
}

  .railLabel {
    font-size: 8px;
}

  .gameInfo .playerBar {
    padding: 10px 8px;
}

  .timeLine {
    gap: 5px;
}
}

@media (max-width: 900px) {
  .roomLayout {
    flex-direction: column;
}
}

@media (max-width: 600px) {
  .matchContent {
    padding: 6px;
}

  .gameToolbar {
    padding-bottom: 6px;
    margin-bottom: 6px;
}

  .gameToolbar button {
    padding: 5px 20px;
}

  .boardLayout {
    grid-template-columns: minmax(0px, 1fr);
    gap: 5px;
}

  .opponentHand {
    grid-row: 1;
}

  .boardFrame {
    grid-row: 2;
    padding: 5px;
}

  .ownHand {
    grid-row: 3;
}

  .handRail {
    display: flex;
    align-items: center;
    padding: 4px;
    gap: 5px;
}

  .railLabel {
    writing-mode: vertical-rl;
    font-size: 9px;
    margin: 0px;
    letter-spacing: 1px;
}

  .hand {
    flex: 1 1 0%;
    flex-direction: row;
    gap: 3px;
}

  .handPiece {
    flex: 1 1 0%;
    min-height: 37px;
    flex-wrap: nowrap;
    font-size: 11px;
}

  .handPiece img {
    width: min(6vw, 32px);
    height: min(6vw, 32px);
}

  .handPiece span {
    padding: 0px 1px;
}

  .gameInfo {
    grid-row: 4;
    grid-template-columns: repeat(2, minmax(0px, 1fr));
    gap: 5px;
}

  .gameInfo .playerBar {
    padding: 8px;
}

  .playerBar .eyebrow {
    font-size: 9px;
    margin: 0px;
}

  .clock {
    font-size: 27px;
}

  .timeLine {
    margin-top: 2px;
    font-size: 10px;
}

  .gameMessage {
    grid-column: 1 / -1;
    min-height: 85px;
    padding: 12px;
}
}

.square {
  display: block;
}

.square:focus:not(:focus-visible),
.handPiece:focus:not(:focus-visible) {
  outline: none;
}

.roomLayout {
  display: grid;
  grid-template-columns: 145px minmax(0px, 1fr);
}

.matchContent {
  justify-self: center;
  min-width: 0px;
  transform-origin: center top;
}

.hasGame .boardLayout {
  grid-template-columns: 62px 560px 62px minmax(0px, 1fr);
  gap: 8px;
}

.hasGame .boardFrame {
  grid-row: auto;
}

.hasGame .handRail {
  padding: 0px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  grid-row: auto;
}

.hasGame .railLabel {
  writing-mode: horizontal-tb;
  font-size: 10px;
  margin: 2px 0px;
}

.hasGame .hand {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hasGame .opponentHand .hand {
  flex-direction: column-reverse;
}

.hasGame .handPiece {
  display: block;
  padding-bottom: 0px;
}

.hasGame .handPiece img {
  display: block;
  width: 100%;
  height: 100%;
}

.hasGame .handPiece span {
  position: absolute;
  right: 0px;
  bottom: 0px;
}

.hasGame .opponentHand .handPiece span {
  inset: 0px auto auto 0px;
}

.hasGame .gameInfo {
  grid-row: auto;
  grid-template-columns: 1fr;
  gap: 8px;
}

.hasGame .gameMessage {
  grid-column: auto;
}

.hasGame .ownHand {
  align-self: end;
}

.tallLayout .roomLayout {
  display: flex;
  flex-direction: column;
}

.tallLayout .matchContent {
  align-self: center;
}

.tallLayout.hasGame .boardLayout {
  grid-template-columns: minmax(0px, 1fr);
  column-gap: 5px;
}

.tallLayout.hasGame .opponentHand {
  grid-row: 1;
}

.tallLayout.hasGame .boardFrame {
  grid-row: 2;
}

.tallLayout.hasGame .ownHand {
  grid-row: 3;
}

.tallLayout.hasGame .handRail {
  flex-direction: row;
  align-items: center;
  gap: 4px;
  padding: 2px;
}

.tallLayout.hasGame .railLabel {
  writing-mode: vertical-rl;
  font-size: 9px;
  margin: 0px;
}

.tallLayout.hasGame .hand {
  flex-direction: row;
}

.tallLayout.hasGame .opponentHand .hand {
  flex-direction: row-reverse;
}

.tallLayout.hasGame .gameInfo {
  gap: 5px;
}

.tallLayout.hasGame .gameMessage {
  grid-column: 1 / -1;
  min-height: 48px;
  padding: 8px;
}

.hasGame .gameToolbar {
  margin-bottom: 6px;
  padding-bottom: 6px;
}

.promotion {
  border-left: 2px solid var(--control-edge);
  border-top: 2px solid var(--control-edge);
  border-right: 2px solid var(--control-edge);
  border-bottom: 2px solid var(--control-edge);
  border-image: none;
  background: rgb(243, 252, 241);
  box-shadow: rgba(82, 99, 75, 0.15) 0px 12px 32px;
  position: fixed;
  top: 0px;
  left: 0px;
  right: auto;
  width: max-content;
  max-width: calc(-12px + 100vw);
  padding: 12px;
  z-index: 10;
  box-sizing: border-box;
}

.promotion .actions {
  gap: 6px;
  margin-top: 8px;
}

.promotion .actions button {
  padding: 8px 10px;
}

.hasGame .handPiece {
  position: relative;
  padding-top: 0px;
  padding-right: 0px;
  padding-left: 0px;
  border: 0px;
  width: var(--cellPx);
}

.tallLayout.hasGame .handPiece {
  width: var(--cellPx);
}

.hasGame .boardFrame {
  padding: 12px;
  background: var(--board-base);
  border: 0px;
  border-radius: 4px;
  box-shadow: none;
}

.tallLayout.hasGame .boardFrame {
  padding-right: 12px;
  padding-left: 12px;
  background: var(--board-base);
  border: 0px;
  border-radius: 4px;
  box-shadow: none;
}

.board {
  touch-action: manipulation;
  user-select: none;
  position: relative;
  gap: 0px;
  border: var(--board-outerPx) solid var(--board-strong);
  background: var(--board-base);
}

.square,
.square:nth-child(2n) {
  position: relative;
  background: var(--board-base);
  box-shadow: inset -1px -1px var(--board-grid);
}

.square::after {
  content: "";
  position: absolute;
  inset: 0px;
  pointer-events: none;
}

.handPiece.selected::after {
  border: var(--board-markPx) solid transparent;
}

.square.lastOwn {
  background: var(--board-lastOwn);
}

.square.lastOther {
  background: var(--board-lastOther);
}

.square.lastOwn::after,
.square.lastOther::after {
  border-color: var(--board-lastBorder);
}

.square.target {
  background: var(--board-target);
}

.square.target::after {
  border-color: var(--board-targetBorder);
}

.square.selected,
.handPiece.selected {
  background: var(--board-selected);
  box-shadow: none;
}

.square.selected::after {
  border-color: var(--board-selectionBorder);
}

.handPiece.selected::after {
  pointer-events: none;
  border-color: var(--board-selectionBorder);
}

.board::after {
  content: "";
  position: absolute;
  inset: 0px;
  pointer-events: none;
  z-index: 1;
  background: radial-gradient(
      circle at 33.333333% 33.333333%,
      var(--board-strong) 0 var(--board-dotPx),
      transparent calc(var(--board-dotPx) + 0.5px)
    ),
    radial-gradient(
      circle at 66.666667% 33.333333%,
      var(--board-strong) 0 var(--board-dotPx),
      transparent calc(var(--board-dotPx) + 0.5px)
    ),
    radial-gradient(
      circle at 33.333333% 66.666667%,
      var(--board-strong) 0 var(--board-dotPx),
      transparent calc(var(--board-dotPx) + 0.5px)
    ),
    radial-gradient(
      circle at 66.666667% 66.666667%,
      var(--board-strong) 0 var(--board-dotPx),
      transparent calc(var(--board-dotPx) + 0.5px)
    ),
    linear-gradient(
      90deg,
      transparent calc(33.333333% - var(--board-majorPx)),
      var(--board-strong) 0 33.333333%,
      transparent 0 calc(66.666667% - var(--board-majorPx)),
      var(--board-strong) 0 66.666667%,
      transparent 0
    ),
    linear-gradient(
      180deg,
      transparent calc(33.333333% - var(--board-majorPx)),
      var(--board-strong) 0 33.333333%,
      transparent 0 calc(66.666667% - var(--board-majorPx)),
      var(--board-strong) 0 66.666667%,
      transparent 0
    );
}

.handPiece:disabled {
  opacity: 1;
}

.handPiece.emptyHand {
  opacity: var(--board-emptyOpacity);
}

.handPiece.emptyHand span {
  display: none;
}

.queueClock circle,
.queueClock circle:nth-child(2),
.queueClock circle:nth-child(3) {
  stroke: rgb(32, 37, 31);
}

.queueClock {
  position: absolute;
  inset: 0px;
  width: 100%;
  height: 100%;
  margin: 0px;
  overflow: visible;
}

.queueClock circle {
  stroke-width: 6;
  stroke-linecap: round;
}

body:not(.hasGame) .roomLayout {
  display: flex;
  flex-direction: column;
}

body:not(.hasGame) .matchContent {
  width: 100%;
  align-self: center;
}

.hasGame .matchContent {
  overflow-anchor: none;
}

.hasGame .roomLayout {
  display: grid;
  grid-template-columns: minmax(0px, 1fr);
}

.gameToolbar {
  justify-content: flex-end;
}

.hasGame .handPiece span {
  background: var(--board-countBg);
  color: var(--board-countInk);
  border: 0px;
  border-radius: var(--board-countRadiusPx);
  padding: var(--board-countPadY) var(--board-countPadX);
  font-size: min(
    var(--board-countFontPx),
    calc(var(--cellPx) * var(--board-countFontScale))
  );
  line-height: 1.1;
  letter-spacing: -1px;
  font-weight: 600;
  box-shadow: none;
}

.gameArea {
  user-select: none;
}

@media (hover: hover) {
  body:not(.choosingPromotion) .square.hoverable:hover,
  body:not(.choosingPromotion) .handPiece:not(:disabled):hover {
    background: var(--board-hover);
    opacity: var(--board-hoverOpacity);
}
}

.square {
  line-height: 0;
  appearance: none;
  aspect-ratio: 1 / var(--cellRatio);
  overflow: visible;
}

.hasGame .handPiece {
  flex: 0 0 auto;
  min-height: 0px;
  line-height: 0;
  height: calc(var(--cellPx) * var(--cellRatio));
  overflow: visible;
}

.tallLayout.hasGame .handPiece {
  height: calc(var(--cellPx) * var(--cellRatio));
  overflow: visible;
}

.square .pieceVisual,
.hasGame .handPiece .pieceVisual {
  position: absolute;
  top: 0px;
  left: 50%;
  height: 100%;
  width: 100%;
  transform: translateX(-50%);
  pointer-events: none;
}

.square .pieceVisual.flip,
.hasGame .handPiece .pieceVisual.flip {
  transform: translateX(-50%) rotate(180deg);
}

.square .pieceVisual img,
.hasGame .handPiece .pieceVisual img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  transform-origin: center center;
}

.square::after {
  border: var(--board-markPx) solid transparent;
  z-index: 1;
}

.handPiece.selected::after {
  content: "";
  position: absolute;
  inset: 0px;
  z-index: 1;
}

.hasGame .handPiece > span {
  z-index: 2;
  pointer-events: none;
}

.gameMessage #gameRules {
  font-size: 12px;
  line-height: 1.5;
  color: var(--muted);
}

body:not(.tallLayout) .gameInfo .playerBar[data-side="0"] {
  order: 0;
}

body:not(.tallLayout) .gameInfo .playerBar[data-side="1"] {
  order: 1;
}

body:not(.tallLayout) .gameInfo .gameMessage {
  order: 2;
}

.rankUp {
  color: rgb(32, 37, 31);
  font-weight: 700;
}

.gameInfo .playerBar {
  padding-top: 16px;
  padding-bottom: 16px;
}

.playerBar > span:not(.eyebrow) {
  font-size: 24px;
}

.playerBar .timeLine {
  font-size: 16px;
}

.playerBar .clock {
  font-size: 46px;
}

.formationBoard {
  display: grid;
  grid-template-columns: repeat(9, minmax(0px, 1fr));
  background: rgb(217, 183, 122);
  padding: 6px;
  border: 1px solid rgb(138, 113, 81);
  user-select: none;
  touch-action: manipulation;
  gap: 0px;
}

.formSquare {
  display: flex;
  position: relative;
  align-items: center;
  justify-content: center;
  min-width: 0px;
  aspect-ratio: 1 / 1.1;
  padding: 0px;
  margin: 0px;
  border-width: 0px 1px 1px 0px;
  border-style: none solid solid none;
  border-color: currentcolor rgb(143, 121, 91) rgb(143, 121, 91) currentcolor;
  border-image: none;
  border-radius: 0px;
  background: rgb(229, 189, 125);
  box-shadow: none;
  color: rgb(24, 32, 25);
}

.formSquare:nth-child(9n+1) {
  border-left: 1px solid rgb(143, 121, 91);
}

.formSquare:nth-child(-n+9) {
  border-top: 1px solid rgb(143, 121, 91);
}

.formSquare img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.formSquare:hover {
  filter: brightness(1.06);
}

.formationSlots {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
  margin: 20px 0px;
}

.formPreview:not(.formationBoard) {
  padding: 30px 0px;
  color: rgb(154, 176, 188);
}

.roomView .promotion::after {
  border-right: 2px solid rgb(136, 136, 136);
  border-bottom: 2px solid rgb(136, 136, 136);
}

.roomView .promotion::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-image: none;
  pointer-events: none;
  border-width: 2px 0px 0px 2px;
  border-style: solid none none solid;
  border-color: rgb(136, 136, 136) currentcolor currentcolor rgb(136, 136, 136);
  top: 0px;
  left: 0px;
}

.roomView .promotion::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-image: none;
  pointer-events: none;
  bottom: 0px;
  right: 0px;
  border-left: 0px;
  border-top: 0px;
}

.roomView .playerBar {
  border-radius: 2px;
}

.roomView .gameToolbar button:hover:not(:disabled) {
  text-decoration: none;
}
.roomView .gameToolbar button:hover:not(:disabled):where(:not(.uiAction)){
  background: rgba(225, 239, 221, 0.15);
  border-color: rgb(140, 184, 144);
}

.playerRank {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 18px;
  color: rgb(32, 37, 31);
}

.playerRank img {
  width: 32px;
  height: 32px;
  object-fit: contain;
}

.playerRank[hidden],
body.tallLayout .playerRank {
  display: none;
}

.playerRate {
  font-size: 18px;
  line-height: 1.4;
  margin-top: 5px;
  color: rgb(40, 99, 57);
  font-variant-numeric: tabular-nums;
}

.boardColumn {
  min-width: 0px;
}

.replaySpace {
  height: var(--replayHeight);
  display: flex;
  justify-content: center;
  align-items: center;
}

#replayControls {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 5px;
  max-width: 100%;
}

:where(#replayControls) button {
  padding: 4px 10px;
  font-size: 14px;
  white-space: nowrap;
}

#replayControls button:not(.uiAction):disabled {
  opacity: 0.4;
}

#replayControls button:not(.uiAction):not(:disabled):hover {
  background: var(--control-hover);
}

.gameArea:has(#replayControls:not([hidden])) #resign {
  visibility: hidden;
}

.tallLayout.hasGame .boardColumn {
  grid-row: 2;
}

.tallLayout.hasGame .boardColumn .boardFrame {
  grid-row: auto;
}

.playerBar #myName,
.playerBar #otherName {
  display: block;
  width: 100%;
  overflow: hidden;
  white-space: nowrap;
  line-height: 1.4;
}

.playerId {
  display: block;
  white-space: nowrap;
}

.identityText {
  display: inline-block;
  white-space: nowrap;
}

.playerId {
  width: 100%;
  overflow: hidden;
  line-height: 1.4;
  color: var(--muted);
  font-size: 14px;
  margin: 2px 0px;
}

.roomView .gameToolbar button {
  text-decoration: none;
}
.roomView .gameToolbar button:where(:not(.uiAction)){
  border-radius: 2px;
  background: var(--hud-surface);
  border: 1px solid var(--hud-edge);
  color: var(--hud-ink);
  box-shadow: var(--control-shadow);
  text-shadow: rgba(255, 255, 255, 0) 0px 1px 2px;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.roomView #replayControls button:not(.uiAction) {
  background: var(--hud-surface);
  border: 1px solid var(--hud-edge);
  color: var(--hud-ink);
  box-shadow: var(--control-shadow);
  text-shadow: rgba(255, 255, 255, 0) 0px 1px 2px;
  text-decoration: none;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
}
.roomView .gameToolbar button:not(:disabled):hover:where(:not(.uiAction)),
.roomView #replayControls button:not(.uiAction):not(:disabled):hover:where(:not(.uiAction)){
  background: var(--hud-hover);
  border-color: rgb(140, 184, 144);
  box-shadow: var(--control-hover-shadow);
}
.roomView .gameToolbar button:disabled:where(:not(.uiAction)),
.roomView #replayControls button:not(.uiAction):disabled:where(:not(.uiAction)){
  background: var(--control-surface);
  color: rgb(32, 37, 31);
  box-shadow: none;
}

.roomView .playerBar.self {
  border-left-color: var(--control-edge);
}

.roomView .playerBar .clock {
  color: rgb(32, 37, 31);
  text-shadow: rgba(255, 255, 255, 0) 0px 2px 3px;
}

.roomView .playerBar .clock.lowTime {
  color: rgb(181, 43, 40);
}

.roomView .playerRate,
.roomView #gameRules {
  color: rgb(40, 99, 57);
}

.roomView .promotion {
  position: fixed;
  border-width: 1px;
  border-style: solid;
  border-image: none;
}

.roomView .promotion > p {
  border-left-width: 3px;
  border-left-style: solid;
  padding-left: 10px;
}

.roomView .playerRank img {
  width: 48px;
  height: 48px;
}

.roomView .playerId {
  font-size: 16px;
  color: rgb(82, 96, 79);
}

.roomView .gameToolbar {
  padding-top: 0px;
  margin-top: 0px;
}

.playerCharacter {
  display: block;
  width: var(--characterPx);
  height: var(--characterPx);
  margin: 0px;
  flex: 0 0 auto;
}

.handCharacter,
.tallLayout .playerCharacter {
  display: none;
}

.tallLayout.hasGame .handCharacter:not([hidden]) {
  display: block;
  flex: 0 0 auto;
}

body:not(.tallLayout) .handRail .handCharacter {
  display: none !important;
}

.playerIdentity {
  display: flex;
  align-items: center;
  gap: var(--identityGap);
  min-width: 0px;
}

.playerIdentity > span {
  flex: 1 1 0%;
  min-width: 0px;
  font-weight: 700;
}

.roomView .timeLine {
  justify-content: flex-end;
  text-align: right;
}

.playerStats {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0px;
}

.roomView .playerStats .playerRate {
  margin: 0px;
  font-size: 16px;
  white-space: nowrap;
}

.roomView .playerStats .playerRank:not([hidden]) {
  min-width: 0px;
  font-size: 16px;
}

.playerStats .playerRank span {
  min-width: 0px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.playerStats .playerRank img {
  flex: 0 0 auto;
}

.tallLayout.hasGame .handCharacter:not([hidden]) {
  width: min(var(--cellPx), var(--handCharacterPx));
  height: min(calc(var(--cellPx) * var(--cellRatio)), var(--handCharacterPx));
}

@media (max-width: 600px) {
  .roomView .playerStats .playerRate,
  .roomView .playerStats .playerRank:not([hidden]) {
    font-size: 13px;
}
}

.roomView .gameInfo .playerBar {
  padding-top: 10px;
  padding-bottom: 10px;
}

.roomView .playerStats {
  display: block;
}

.roomView .playerStats .playerRank:not([hidden]) {
  gap: 4px;
  display: block;
  white-space: normal;
  overflow-wrap: anywhere;
  margin-top: 2px;
}

.promotionHologram {
  display: inline-block;
  white-space: nowrap;
  font-weight: 900;
  font-size: 1.35em;
  letter-spacing: 0.08em;
  margin-left: 8px;
  color: rgb(255, 255, 255);
  background: linear-gradient(110deg, rgb(255, 255, 255) 5%, rgb(130, 255, 255) 20%, rgb(255, 255, 255) 35%, rgb(255, 178, 255) 50%, rgb(255, 244, 163) 65%, rgb(255, 255, 255) 80%) 0% 0% / 250% 100% text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(rgb(165, 255, 255) 0px 0px 3px);
  animation: promotionShimmer var(--promotion-shimmer) linear infinite;
}

@keyframes promotionShimmer {
0% { background-position: 200% 50%; filter: drop-shadow(rgb(165, 255, 255) 0px 0px 2px); }
  50% { filter: drop-shadow(rgb(255, 255, 255) 0px 0px 6px); }
  100% { background-position: -50% 50%; filter: drop-shadow(rgb(165, 255, 255) 0px 0px 2px); }
}

@media (max-width: 600px), (max-height: 460px) {
  .promotionHologram {
    font-size: 1.2em;
    margin-left: 4px;
}
}

@media (prefers-reduced-motion: reduce) {
  .promotionHologram {
    animation: auto ease 0s 1 normal none running none;
}
}

.handClock {
  display: none;
}

.tallLayout.hasGame .hand {
  flex: 0 0 auto;
}

.tallLayout.hasGame .handClock {
  display: flex;
  flex: 1 1 0px;
  white-space: nowrap;
  line-height: 1.2;
}

.tallLayout.hasGame .handClock small {
  font-size: 10px;
}

.tallLayout.hasGame .opponentHand .handClock {
  order: 1;
}

.tallLayout.hasGame .opponentHand .hand {
  order: 2;
}

.tallLayout.hasGame .replaySpace {
  grid-row: 4;
}

.tallLayout.hasGame .replaySpace:has(#replayControls[hidden]) {
  display: none;
}

.tallLayout.hasGame .gameInfo {
  grid-template-columns: repeat(2, minmax(0px, 1fr));
  grid-row: 5;
}

.tallLayout.hasGame .matchContent {
  padding-right: 6px;
  padding-bottom: 6px;
  padding-left: 6px;
}

.roomView .promotion {
  background: linear-gradient(135deg, #f5f8ee, #e9f0e3);
  color: var(--control-ink);
  border-color: rgb(137, 157, 131);
  box-shadow: rgba(46, 65, 42, 0.23) 0px 8px 24px, rgba(255, 255, 255, 0.19) 0px 1px inset;
}

.roomView .promotion > p {
  border-left-color: rgb(255, 136, 0);
}

.roomView .promotion .actions button {
  font-weight: 700;
  color: var(--control-ink);
  background: linear-gradient(to bottom, #fffef9, #f2f3e7);
  border-color: rgb(137, 157, 131);
}

.roomView .promotion .actions button:hover,
.roomView .promotion .actions button:focus-visible {
  color: var(--control-ink);
  background: linear-gradient(to bottom, #f8f9ec, #e4eedb);
  border-color: var(--theme-hover);
}

.roomView .queueClock circle {
  stroke: rgb(158, 175, 136);
}

.roomView .queueClock circle:nth-child(2) {
  stroke: rgb(115, 156, 145);
}

.roomView .queueClock circle:nth-child(3) {
  stroke: rgb(39, 102, 88);
}

.roomView .gameMessage {
  border-radius: 2px;
  color: var(--theme-ink);
  background: var(--theme-card);
  border-color: var(--theme-line);
  box-shadow: var(--theme-shadow);
}

.roomView .playerBar {
  background: var(--theme-card);
  border-color: var(--theme-line);
  box-shadow: var(--theme-shadow);
}

.roomView .playerBar.self {
  background: rgb(241, 243, 223);
}

body.roomView .hand {
  background: rgb(150, 107, 67);
  border-color: rgb(114, 80, 49);
}

body.roomView .handPiece.emptyHand {
  visibility: hidden;
}

body.roomView .gameInfo .playerBar,
body.roomView .gameInfo .gameMessage {
  border-color: transparent;
  border-radius: 6px 4px;
  background: rgb(255, 253, 245);
}

body.roomView .gameInfo .playerBar.self {
  background: rgb(237, 245, 238);
}

body.roomView .gameToolbar {
  border-bottom: 0px;
  box-shadow: none;
}

body.roomView #resign {
  background: linear-gradient(rgb(121, 91, 67), rgb(97, 70, 47));
  color: rgb(255, 255, 255);
  border-color: rgb(80, 57, 39);
  box-shadow: rgb(73, 53, 36) 0px 2px 0px, rgba(255, 255, 255, 0.19) 0px 1px 0px inset;
}

body.roomView #resign small {
  display: block;
  color: rgb(255, 255, 255);
  font-size: 9px;
  line-height: 10px;
  font-weight: 500;
  letter-spacing: 0.4px;
}

body.roomView #resign:hover:not(:disabled) {
  background: linear-gradient(rgb(133, 100, 74), rgb(107, 77, 52));
  color: rgb(255, 255, 255);
  border-color: rgb(230, 132, 40);
  box-shadow: rgb(73, 53, 36) 0px 2px 0px, rgba(237, 137, 45, 0.44) 0px 0px 4px;
}

body.roomView #resign:active:not(:disabled) {
  background: rgb(97, 70, 47);
  box-shadow: rgb(73, 53, 36) 0px 1px 0px, rgba(0, 0, 0, 0.2) 0px 1px 2px inset;
}

body.roomView #resign:disabled {
  opacity: 0.5;
}

body.roomView #resign {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 4px 40px;
  min-width: 0px;
  font-size: 15px;
  line-height: 17px;
  border-width: 1px;
  border-style: solid;
  border-image: none;
  border-radius: 5px;
  font-weight: 800;
}

.gameBackdropHost {
  position: relative;
  isolation: isolate;
}

.gameBackdropHost > .matchContent {
  position: relative;
  z-index: 1;
}

.gameBackdrop {
  position: absolute;
  inset: 0px;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
  contain: strict;
  background: rgb(233, 242, 223);
}

.gameBackdrop .motionShape {
  position: absolute;
  pointer-events: none;
  transform-origin: center center;
}

.gameBackdrop .motionCone {
  inset: -25%;
  background: conic-gradient(from 35deg at 42% 48%, rgba(203, 233, 187, 0), rgba(151, 199, 123, 0.565) 60deg, rgba(255, 255, 215, 0.69) 115deg, rgba(133, 187, 170, 0.396) 180deg, rgba(215, 240, 177, 0.627) 250deg, rgba(203, 233, 187, 0));
}

.gameBackdrop .coveragePlane {
  position: absolute;
  background-size: 180px 180px;
  opacity: 0.8;
  background-image: linear-gradient(135deg, rgba(96, 123, 101, 0.37), rgba(214, 223, 177, 0.37) 50%, rgba(130, 152, 120, 0.46));
}

.gameBackdrop .coveragePlane.secondary {
  opacity: 0.7;
  background-image: repeating-linear-gradient(45deg, rgba(123, 148, 101, 0.314) 0px, rgba(123, 148, 101, 0.314) 42px, rgba(239, 244, 205, 0.314) 42px, rgba(239, 244, 205, 0.314) 80px, rgba(91, 124, 98, 0.25) 80px, rgba(91, 124, 98, 0.25) 127.279px);
}

.gameBackdrop .motionRipple {
  border-style: solid;
  border-radius: 50%;
  background: none;
  opacity: 0;
}

.gameBackdrop .motionConcrete {
  border-radius: 0px;
  background: radial-gradient(ellipse at 15% 24%,var(--tone),transparent 58%),
 radial-gradient(ellipse at 72% 62%,var(--tone),transparent 62%),
 radial-gradient(ellipse at 46% 80%,#f4f5dc4a,transparent 45%),
 radial-gradient(circle,#496d492c .7px,transparent 1.5px) 0 0/7px 9px,
 radial-gradient(circle,#fbffec40 .9px,transparent 1.8px) 3px 5px/11px 13px;
}

.gameBackdrop .motionStreak {
  left: 0px;
  top: 0px;
  transform-origin: center center;
  border-radius: 1px;
  background: var(--tone);
}

.gameBackdrop .motionConcrete {
  mask-image: radial-gradient(rgb(0, 0, 0) 12%, rgba(0, 0, 0, 0.733) 40%, transparent 71%);
  background-color: rgba(155, 169, 134, 0.094);
}

#board .square {
  position: relative;
}

#board .moveAura {
  position: absolute;
  inset: 0px;
  pointer-events: none;
  border-radius: 4px;
  z-index: 3;
  opacity: var(--auraOpacity, 1);
  box-shadow: rgb(202, 147, 152) 0px 0px 0px 3px inset;
}

#board .moveAura::before {
  content: "";
  position: absolute;
  inset: 0px;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: rgba(0, 0, 0, 0.6) 0px 0px 3px 1px, rgba(0, 0, 0, 0.333) 0px 0px 8px 2px;
  transform: scale(var(--auraScale));
}

#board .moveAura::after {
  content: "";
  position: absolute;
  inset: 3px;
  pointer-events: none;
  border-radius: 2px;
  background: radial-gradient(at 35% 25%, rgba(255, 255, 255, 0.533) 0px, transparent 65%), linear-gradient(145deg, rgba(255, 234, 232, 0.667), rgba(255, 169, 176, 0.47) 60%, rgba(247, 126, 145, 0.39));
  box-shadow: rgba(255, 255, 255, 0.6) 0px 1px 2px inset, rgba(202, 147, 152, 0.15) 0px -2px 4px inset;
}

#board .moveReach {
  position: absolute;
  inset: 0px;
  pointer-events: none;
  border-radius: 4px;
  z-index: 3;
  opacity: var(--auraOpacity, 1);
  box-shadow: rgb(154, 126, 112) 0px 0px 0px 3px inset;
}

#board .moveReach::after {
  content: "";
  position: absolute;
  inset: 3px;
  pointer-events: none;
  border-radius: 2px;
  background: conic-gradient(from 35deg, rgba(37, 23, 16, 0.11), rgba(37, 23, 16, 0.32) 120deg, rgba(37, 23, 16, 0.16) 240deg, rgba(37, 23, 16, 0.11));
}

.formSquare.selected {
  background: rgb(194, 228, 250);
  box-shadow: rgb(96, 159, 201) 0px 0px 0px 3px inset;
}

.formSquare.target {
  background: rgb(224, 242, 252);
  box-shadow: rgb(140, 190, 219) 0px 0px 0px 2px inset;
}

.playerBar.self .selfBadge {
  display: inline-block;
  flex: 0 0 auto;
  margin-left: 5px;
  padding: 1px 6px;
  border: 1px solid rgb(99, 165, 190);
  border-radius: 5px;
  background: rgb(225, 245, 255);
  color: rgb(18, 81, 106);
  font-size: 12px;
  font-weight: 800;
  line-height: 1.5;
  white-space: nowrap;
}

.tallLayout.hasGame .handClock {
  align-items: baseline;
  justify-content: center;
  gap: 1px;
  font-size: 16px;
  min-width: calc(4ch + 12px);
}

.tallLayout.hasGame .handClock .clock {
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
  font-size: 16px;
}

.tallLayout.hasGame .hand {
  gap: 1px;
}

.replaySpace:has(.kifuShare) {
  height: auto;
  min-height: var(--replayHeight);
  flex-wrap: wrap;
  gap: 4px 6px;
  padding: 2px 0px;
  box-sizing: border-box;
}

.replaySpace .kifuShare {
  display: contents;
}

.replaySpace .kifuShareButtons {
  flex-wrap: nowrap;
  gap: 5px;
}

.replaySpace .kifuShareButtons :is(button, a) {
  padding: 4px 6px;
  font-size: 14px;
  white-space: nowrap;
}

.replaySpace .kifuShare [data-share-status] {
  flex-basis: 100%;
  margin: 0px;
  text-align: center;
}

.replaySpace .kifuShare input {
  flex-basis: 100%;
}

.creatureSection {
  margin: 12px 0px;
  padding: 14px 16px;
  background: rgb(255, 253, 245);
  color: rgb(40, 59, 54);
  scroll-margin-top: 12px;
}

.creatureCards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0px, 1fr));
  gap: 18px;
  color: rgb(40, 59, 54);
}

.creatureCard {
  min-width: 0px;
  padding: 18px 20px 22px;
  text-align: center;
  background: radial-gradient(at 50% 32%, rgb(255, 255, 255) 0%, rgb(243, 247, 233) 52%, rgb(249, 244, 231) 100%);
  border: 2px solid rgb(123, 136, 116);
  border-radius: 24px 20px 26px 18px / 20px 24px 19px 25px;
  box-shadow: rgb(216, 221, 202) 0px 4px 0px, rgba(40, 59, 54, 0.063) 0px 8px 18px;
  overflow-wrap: anywhere;
}

.creatureCard:empty {
  background: none;
  border-color: transparent;
  box-shadow: none;
  min-height: 24px;
}

.creatureCard:nth-child(2) {
  background: radial-gradient(at 50% 32%, rgb(255, 255, 255) 0%, rgb(246, 238, 231) 52%, rgb(249, 244, 231) 100%);
}

.creatureCard:nth-child(2):empty {
  background: none;
}

.creatureCard .creaturePlayer {
  text-shadow: none;
  letter-spacing: 0px;
  margin: 0px 0px 8px;
  padding: 0px 0px 8px;
  border-width: 0px 0px 1px;
  border-style: none none solid;
  border-color: currentcolor currentcolor rgba(118, 136, 120, 0.22);
  border-image: none;
  background: none;
  box-shadow: none;
  color: rgb(52, 74, 66);
  font-size: 17px;
  line-height: 1.5;
}

.creatureEmoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  font-size: 88px;
  line-height: 1.35;
  filter: saturate(1.08) drop-shadow(rgba(78, 98, 73, 0.15) 0px 5px 3px);
  margin: 4px auto 12px;
}

.creatureCard .creatureKana {
  margin: 0px;
  color: rgb(101, 117, 104);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1px;
}

.creatureCard .creatureName {
  margin: 3px 0px;
  padding: 0px;
  background: none;
  border: 0px;
  box-shadow: none;
  color: rgb(41, 63, 53);
  font-size: 28px;
  line-height: 1.3;
}

.creatureCard .creatureEnglish {
  margin: 4px 0px 14px;
  color: rgb(115, 120, 110);
  font-size: 13px;
}

.creatureCard .creatureMessage {
  margin: 0px;
  text-align: left;
  font-size: 16px;
  line-height: 1.85;
  font-weight: 500;
  color: rgb(52, 70, 61);
}

.creatureDialog {
  box-sizing: border-box;
  width: 760px;
  max-width: calc(-24px + 100vw);
  max-height: calc(100dvh - 32px);
  padding: 20px;
  background: rgb(255, 253, 245);
  border: 2px solid rgb(115, 127, 107);
  border-radius: 22px;
  color: rgb(40, 59, 54);
  overflow: auto;
  box-shadow: rgba(24, 37, 29, 0.333) 0px 18px 60px;
}

.creatureDialog::backdrop {
  background: rgba(24, 37, 29, 0.6);
}

.creatureHeading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.creatureHeading h2 {
  margin: 0px;
  padding: 0px;
  background: none;
  border: 0px;
  box-shadow: none;
  font-size: 24px;
  color: rgb(40, 59, 54);
}

.creatureHeading button {
  flex-shrink: 0;
}

:where(#replayControls) .fortuneAnchor {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  text-decoration: none;
  font-weight: 700;
  font-size: 14px;
}

#replayControls .fortuneAnchor:not(.uiAction):hover {
  border-color: rgb(227, 139, 40);
  box-shadow: rgba(227, 139, 40, 0.25) 0px 0px 0px 2px;
}

@media (max-width: 600px) {
  .creatureCards {
    grid-template-columns: minmax(0px, 1fr);
    gap: 14px;
}

  .creatureDialog {
    padding: 14px;
}

  .creatureCard {
    padding: 14px 16px 18px;
}

  .creatureEmoji {
    font-size: 76px;
}

  .creatureSection {
    padding: 12px;
}

  .creatureHeading h2 {
    font-size: 22px;
}
}

.tallLayout.hasGame .boardLayout {
  row-gap: 0px;
}

.tallLayout.hasGame .boardFrame {
  padding-top: 0px;
  padding-bottom: 0px;
  margin-top: 0px;
  margin-bottom: 0px;
}

.tallLayout.hasGame .matchContent {
  padding-top: 0px;
}

.tallLayout.hasGame .gameToolbar {
  margin-bottom: 0px;
  padding-bottom: 0px;
}

body.roomView:not(.casualPlay):not(.tallLayout) #gamePanel {
  position: relative;
}

body.roomView:not(.casualPlay):not(.tallLayout) #gamePanel > .gameToolbar {
  position: absolute;
  left: calc(708px);
  right: 0px;
  bottom: 8px;
  justify-content: center;
  margin: 0px;
  padding: 0px;
  z-index: 2;
}

body.roomView:not(.casualPlay):not(.tallLayout) #gamePanel .gameInfo {
  padding-bottom: 64px;
}

.movePiece {
  position: absolute;
  margin: 0px;
  pointer-events: none;
  transform-origin: 0px 0px;
}

.movePiece img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
}

.movePiece.flip img {
  transform: rotate(180deg);
}

#board .pieceVisual.moveHidden {
  visibility: hidden;
}

body.roomView.hasGame .gameInfo .playerBar {
  flex: 0 0 auto;
  margin: 0px;
  color: var(--player-ink);
}

body.roomView.hasGame .gameInfo .playerBar[data-side="0"] {
  --player-paper: #191f1f;
  --player-ink: #f7f7f7;
  --player-edge: #f7f7f7;
}

body.roomView.hasGame .gameInfo .playerBar::before {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  clip-path: var(--player-shape);
  border: 0px;
  border-radius: 0px;
  box-shadow: none;
  content: "" !important;
  inset: 0px;
  background: var(--player-edge);
}

body.roomView.hasGame .gameInfo .playerBar::after {
  position: absolute;
  z-index: -1;
  pointer-events: none;
  clip-path: var(--player-shape);
  border: 0px;
  border-radius: 0px;
  box-shadow: none;
  content: "" !important;
  inset: 3px;
  background: var(--player-paper);
}

body.roomView.hasGame .gameInfo .playerBar.opponent {
  order: 0;
}

body.roomView.hasGame .gameInfo .versusMark {
  order: 1;
}

body.roomView.hasGame .gameInfo .playerBar.self {
  order: 2;
}

body.roomView.hasGame .gameInfo .gameMessage {
  order: 3;
}

body.roomView.hasGame .gameInfo .gameToolbar {
  order: 4;
}

body.roomView.hasGame .gameInfo .playerIdentity {
  margin: 0px 0px 8px;
  min-width: 0px;
  font-size: 24px;
  line-height: 1.3;
  font-weight: 800;
}

body.roomView.hasGame .gameInfo .playerDetails {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0px;
}

body.roomView.hasGame .gameInfo .playerMetadata {
  flex: 1 1 0%;
  min-width: 0px;
}

body.roomView.hasGame .gameInfo .playerDetails .playerCharacter {
  width: 64px;
  height: 72px;
  object-fit: contain;
}

body.roomView.hasGame .gameInfo .playerBar .playerId,
body.roomView.hasGame .gameInfo .playerBar .playerRate,
body.roomView.hasGame .gameInfo .playerBar .playerRank,
body.roomView.hasGame .gameInfo .playerBar .timeLine,
body.roomView.hasGame .gameInfo .playerBar .clock {
  color: inherit;
  text-shadow: none;
}

body.roomView.hasGame .gameInfo .playerBar .playerId,
body.roomView.hasGame .gameInfo .playerBar .playerRate,
body.roomView.hasGame .gameInfo .playerBar .playerRank {
  margin: 0px;
  font-size: 16px;
  line-height: 1.5;
}

body.roomView.hasGame .gameInfo .playerBar .timeLine {
  margin: 8px 0px 0px;
  padding: 6px 0px 0px;
  border-top: 2px solid rgb(124, 167, 149);
  justify-content: flex-end;
  gap: 6px;
  font-weight: 700;
  white-space: nowrap;
}

body.roomView.hasGame .gameInfo .playerBar .timeLine .clock {
  font-size: 38px;
  line-height: 1.15;
}

body.roomView.hasGame .gameInfo .playerBar .clock.lowTime {
  color: rgb(228, 78, 70);
}

body.roomView.hasGame .gameInfo .versusMark::before,
body.roomView.hasGame .gameInfo .versusMark::after {
  content: "";
  width: 42px;
  height: 3px;
  background: rgb(36, 90, 67);
  border-radius: 50%;
}

body.roomView.tallLayout.hasGame .gameInfo .playerBar {
  padding: 17px 18px;
}

body.roomView.tallLayout.hasGame .gameInfo .playerIdentity {
  margin-bottom: 5px;
}

body.roomView.tallLayout.hasGame .gameInfo .playerBar .timeLine .clock {
  font-size: 32px;
}

body.roomView.tallLayout.hasGame .gameInfo .playerDetails .playerCharacter,
body.roomView.hasGame .gameInfo .playerBar > .inkOutline {
  display: none;
}

.playerMetadata .playerTeam {
  font-size: 14px;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
  margin-bottom: 3px;
}

body.watchMode #resign {
  display: none !important;
}

body.watchMode .gameInfo {
  padding-bottom: 0px !important;
}

body.watchMode #board .square {
  cursor: default;
}

body.watchMode .gameMessage .watchModeLabel {
  font-size: 18px;
  margin: 0px 0px 8px;
}

.watchPlayers {
  display: grid;
  grid-template-columns: minmax(0px, 1fr) auto minmax(0px, 1fr);
  align-items: center;
  gap: 16px;
}

.watchPlayerIcon {
  left: 9px;
  top: 12px;
  object-fit: contain;
  position: static;
  grid-area: 1 / 1 / span 2;
  align-self: center;
  width: 44px;
  height: 50px;
}

@media (max-width: 600px) {
  .watchPlayers {
    gap: 6px;
}

  .watchPlayerIcon {
    left: 5px;
    width: 26px;
    height: 32px;
}
}

body.roomView.hasGame:not(.tallLayout):not(.casualPlay) .boardLayout {
  grid-template-rows: auto auto;
}

body.roomView.hasGame:not(.tallLayout):not(.casualPlay) .opponentHand {
  grid-area: 1 / 1;
}

body.roomView.hasGame:not(.tallLayout):not(.casualPlay) .boardFrame {
  grid-area: 1 / 2;
}

body.roomView.hasGame:not(.tallLayout):not(.casualPlay) .ownHand {
  grid-area: 1 / 3;
  align-self: end;
}

body.roomView.hasGame:not(.tallLayout):not(.casualPlay) .gameInfo {
  grid-area: 1 / 4 / 3;
}

body.roomView.hasGame .gameInfo {
  display: flex;
  flex-direction: column;
  min-width: 0px;
  gap: 4px;
  container-type: inline-size;
}

body.roomView.hasGame .gameInfo .playerBar {
  --player-paper: #f7f7f7;
  --player-ink: #191f1f;
  --player-edge: #191f1f;
  --player-shape: polygon(0 6%,100% 0,100% 94%,6% 100%,0 66%);
  position: relative;
  isolation: isolate;
  box-sizing: border-box;
  border: 0px;
  border-radius: 0px;
  background: transparent;
  box-shadow: none;
  padding: 16px 16px 14px;
}

body.roomView.hasGame .gameInfo .versusMark {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  margin: 0px;
  line-height: 1;
  font-style: italic;
  font-weight: 900;
  color: rgb(25, 31, 31);
  text-shadow: rgb(247, 247, 247) 1px 1px, rgb(247, 247, 247) -1px -1px;
  font-size: 25px;
}

body.roomView.hasGame .gameInfo .gameMessage {
  margin-top: 2px;
  font-size: clamp(12px, 4.8cqw, 14px);
  line-height: 1.4;
}

body.roomView.hasGame .gameInfo .gameMessage p {
  margin: 0px;
}

body.roomView.hasGame .gameInfo .gameMessage p + p:not(:empty) {
  margin-top: 0.4em;
}

body.roomView.hasGame .gameInfo .gameMessage :is(#turnLabel, .myTurnMessage, .watchModeLabel) {
  font-size: 1.2857em;
  line-height: 1.35;
  font-weight: 700;
  margin: 0px;
}

body.roomView.hasGame .gameInfo .gameMessage #gameRules {
  font-size: 0.8571em;
  line-height: 1.4;
}

body.roomView.hasGame .gameInfo .gameMessage :is(#spectatorCount, #watchConnectionNotice, #moveNotice) {
  font-size: 1em;
}

body.roomView.hasGame .gameInfo .gameMessage > :is(p, strong, output):empty {
  display: none;
}

body.roomView.hasGame .gameInfo .gameMessage {
  min-height: 0px;
  padding: 0.5em 0.65em;
  overflow-wrap: anywhere;
  background: linear-gradient(130deg, var(--theme-page), rgb(245, 245, 235));
  color: var(--theme-ink);
}

body.roomView .gameMessage #gameRules {
  color: var(--theme-muted);
}

body.roomView .gameMessage .watchModeLabel {
  color: rgb(40, 90, 80);
}

body.roomView .gameInfo .timeLine {
  border-top-color: rgb(140, 170, 153);
}

body.roomView.tallLayout.hasGame .handPiece {
  container-type: inline-size;
}

body.roomView.tallLayout.hasGame .handPiece > span {
  font-size: clamp(11px, 39cqi, 20px);
  line-height: 1.05;
  letter-spacing: 0px;
  padding: 1px 3px;
  border-radius: 3px;
  font-weight: 800;
  inset: auto 0px 0px auto;
}

body.roomView.tallLayout.hasGame .opponentHand .handPiece > span {
  inset: 0px auto auto 0px;
}

@media (max-width: 900px) {
  body.roomView.tallLayout.hasGame .matchContent {
    padding-left: 0px;
    padding-right: 0px;
}

  body.roomView.tallLayout.hasGame .gameInfo .gameMessage {
    margin-left: 3px;
    margin-right: 3px;
}
}

body.roomView.tallLayout.hasGame .handClock {
  background: rgb(255, 248, 232);
  box-shadow: rgb(168, 140, 96) 0px 0px 0px 1px inset;
  border-radius: 3px;
  color: rgb(25, 31, 31);
}

body.roomView #fortuneDialog #fortuneClose {
  min-height: 36px;
  padding: 6px 12px;
  font-style: inherit;
  font-variant: inherit;
  font-stretch: inherit;
  font-size: inherit;
  line-height: inherit;
  font-family: inherit;
  font-optical-sizing: inherit;
  font-size-adjust: inherit;
  font-kerning: inherit;
  font-feature-settings: inherit;
  font-variation-settings: inherit;
  font-language-override: inherit;
  font-weight: 700;
}

@media (max-width: 600px) {
  body.roomView #fortuneDialog #fortuneClose {
    min-height: 40px;
}
}

/* === 見出し：通常・条件付き・操作状態をまとめて管理 === */

body.resultVisible .roomHeader,
body.resultVisible .gameToolbar {
  position: relative;
  z-index: 101;
}

/* === カード：通常・条件付き・操作状態をまとめて管理 === */

.watchPlayer:hover,
.watchPlayer:focus-visible {
  outline: rgb(230, 132, 40) solid 2px;
}

.watchPlayer {
  min-width: 0px;
  border: 1px solid rgb(206, 203, 181);
  border-radius: 5px;
  color: rgb(36, 58, 72);
  text-decoration: none;
  position: relative;
  display: grid;
  grid-template-columns: 44px minmax(0px, 1fr);
  gap: 3px 10px;
  padding: 10px 10px 7px;
  background: var(--theme-page);
  line-height: 1.4;
}

@media (max-width: 600px) {
  .watchPlayer {
    grid-template-columns: 26px minmax(0px, 1fr);
    gap: 3px 5px;
    padding: 8px 5px;
}
}

body.roomView .watchPlayer.inkInteractive > .inkOutline .inkNormal {
  opacity: 1 !important;
}

body.roomView .watchPlayer.inkInteractive > .inkOutline .inkHot {
  transition: opacity 200ms;
  fill: var(--theme-hover);
}

body.roomView .watchPlayer.inkInteractive > .inkOutline .inkHalo {
  transition: opacity 200ms;
  filter: none;
}

@media (hover: none) {
  body.roomView .watchPlayer.inkInteractive:not(:active):not(:focus-visible) > .inkOutline .inkHot,
  body.roomView .watchPlayer.inkInteractive:not(:active):not(:focus-visible) > .inkOutline .inkHalo {
    opacity: 0;
}
}

body.roomView .watchPlayer.inkInteractive:active > .inkOutline .inkHot {
  opacity: 1;
}

@media (prefers-reduced-motion: reduce) {
  body.roomView .watchPlayer.inkInteractive > .inkOutline .inkHot,
  body.roomView .watchPlayer.inkInteractive > .inkOutline .inkHalo {
    transition: none !important;
}
}

/* === 結果表示：通常・条件付き・操作状態をまとめて管理 === */

.resultPanel {
  margin-top: 16px;
  border-left: 3px solid var(--control-edge);
}

.resultPanel p {
  margin: 8px 0px;
}

.resultDialog {
  box-sizing: border-box;
  width: 440px;
  max-width: calc(-24px + 100vw);
  max-height: calc(100dvh - 24px);
  overflow: auto;
  margin: auto;
  padding: 24px;
  background: rgb(12, 27, 37);
  color: rgb(233, 240, 244);
  border: 1px solid rgb(71, 103, 121);
}

.resultDialog::backdrop {
  background: transparent;
}

.resultDialog h2 {
  margin: 8px 0px 12px;
  font-size: 28px;
}

.resultDialog p {
  margin: 10px 0px;
}

.resultDialog .actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}

.resultDialog .actions > * {
  padding: 9px 12px;
}

#resultSave {
  color: rgb(32, 37, 31);
  font-size: 13px;
}

.roomView .resultDialog,
.roomView .promotion {
  border-radius: 2px;
}

.roomView .resultDialog::before {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-image: none;
  pointer-events: none;
}

.roomView .resultDialog::after {
  border-right: 2px solid rgb(136, 136, 136);
  border-bottom: 2px solid rgb(136, 136, 136);
}

.roomView .resultDialog::before {
  border-top: 2px solid rgb(136, 136, 136);
  border-left: 2px solid rgb(136, 136, 136);
  top: 0px;
  left: 0px;
  border-right: 0px;
  border-bottom: 0px;
}

.roomView .resultDialog::after {
  content: "";
  position: absolute;
  width: 20px;
  height: 20px;
  border-image: none;
  pointer-events: none;
  bottom: 0px;
  right: 0px;
  border-left: 0px;
  border-top: 0px;
}

.roomView .resultDialog::backdrop {
  background: transparent;
}

.roomView .resultDialog {
  font-size: 20px;
  font-weight: 700;
}

.roomView .resultDialog #resultTitle {
  border: 0px;
}

.roomView .resultDialog[data-outcome="win"] #resultTitle {
  color: rgb(241, 255, 248);
}

.roomView #resultSave {
  font-size: 17px;
  font-weight: 700;
}

.roomView .resultDialog .actions :is(button, a) {
  font-size: 18px;
  font-weight: 700;
}

.resultRank {
  display: flex;
  align-items: center;
  gap: 14px;
}

.resultRank img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  flex-shrink: 0;
}

.resultRank p {
  min-width: 0px;
  overflow-wrap: anywhere;
}

@media (max-width: 600px) {
  .roomView .resultDialog {
    font-size: 18px;
}

  .roomView .resultDialog .actions :is(button, a) {
    font-size: 16px;
}

  .resultRank img {
    width: 48px;
    height: 48px;
}
}

.roomView .resultDialog {
  width: 980px;
  padding: 0px;
  background: transparent;
  border: 0px;
  box-shadow: none;
  color: rgb(255, 255, 255);
}

.roomView .resultDialog::before,
.roomView .resultDialog::after {
  display: none;
}

.resultFan {
  position: relative;
  height: 420px;
  rotate: var(--result-tilt, 0deg);
  translate: 0 var(--result-offset-y, 0px);
  transform-origin: center 65%;
}

.roomView .resultDialog #ratingDetails {
  border: 0px;
}

.roomView :is(.resultBand, .resultBandSurface) {
  --band: #086848;
  position: absolute;
  isolation: isolate;
  box-sizing: border-box;
  left: 0px;
  width: 100%;
  height: 420px;
  margin: 0px;
  translate: none;
  transform: none;
  transform-origin: -80% 65%;
  border: 0px;
  box-shadow: none;
  padding: 0px;
  color: rgb(255, 255, 255);
  background: none !important;
}

.roomView :is(.resultBand, .resultBandSurface)::before {
  position: absolute;
  z-index: -1;
  left: 50%;
  top: 0px;
  bottom: 0px;
  background: var(--band);
}

.roomView :is(.resultBand, .resultBandSurface) > div {
  position: absolute;
  left: 20%;
  top: 100px;
  rotate: -7deg;
}

.roomView .resultSash {
  top: 0px;
  z-index: 3;
}

.roomView .resultDialog[data-outcome="win"] .resultSash {
  --band: #08764f;
}

.roomView .resultDialog[data-outcome="lose"] :is(.resultBand, .resultBandSurface) {
  --band: #175678;
}

.roomView .resultDialog[data-outcome="lose"] .resultRate {
  --band: #103e60;
}

.roomView .resultDialog[data-outcome="lose"] .resultTitleBand {
  --band: #092940;
}

.roomView .resultRate {
  --band: #075139;
  top: 0px;
}

.roomView .resultRate > div {
  top: 225px;
  rotate: -2deg;
}

.roomView .resultTitleBand {
  --band: #063c30;
  top: 0px;
}

.roomView .resultTitleBand > div {
  top: 295px;
  rotate: 3deg;
}

.roomView .resultDialog #resultTitle {
  margin: 0px;
  padding: 0px;
  text-align: left;
  color: rgb(255, 255, 255);
  white-space: nowrap;
}

.roomView :is(.resultBand, .resultBandSurface) p {
  margin-top: 8px;
  margin-left: 0px;
  color: rgb(255, 255, 255);
}

.roomView .resultDialog .rankUp {
  color: rgb(255, 255, 255);
}

.roomView .resultDialog #resultSave {
  color: rgb(255, 255, 255);
  text-shadow: rgb(0, 0, 0) 0px 1px 4px;
  text-align: center;
}

@media (max-width: 600px) {
  .roomView :is(.resultBand, .resultBandSurface) > div {
    left: 12%;
    top: 140px;
}

  .roomView .resultRate > div {
    top: 225px;
}

  .roomView .resultTitleBand > div {
    top: 290px;
}

  .roomView .resultDialog .actions > * {
    padding: 8px;
    font-size: 14px;
}

  .roomView .resultRank {
    gap: 8px;
}
}

@media (max-height: 600px) {
  .resultFan,
  .roomView :is(.resultBand, .resultBandSurface) {
    height: 300px;
}

  .roomView :is(.resultBand, .resultBandSurface) > div {
    top: 70px;
}

  .roomView .resultRate > div {
    top: 160px;
}

  .roomView .resultTitleBand > div {
    top: 205px;
}
}

.roomView .resultDialog {
  max-width: calc(-24px + 100vw);
  overflow: visible;
  position: fixed;
  inset: 0px 0px var(--result-bottom-inset, 0px);
  height: max-content;
  margin: auto;
  z-index: 102;
  pointer-events: none;
}

.roomView .resultDialog .actions {
  background: var(--control-surface);
  border: 1px solid var(--control-edge);
  justify-content: center;
}

.endActions {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-left: auto;
}

.endActions a {
  display: inline-block;
  padding: 8px 18px;
  border: 1px solid var(--control-edge);
  background: var(--control-surface);
  color: var(--control-ink);
  text-decoration: none;
}

@media (max-width: 600px) {
  .endActions :is(a, button) {
    padding: 5px 8px;
    font-size: 13px;
}
}

.roomView .endActions :is(button, a) {
  background: var(--hud-surface);
  border: 1px solid var(--hud-edge);
  color: var(--hud-ink);
  box-shadow: var(--control-shadow);
  text-shadow: rgba(255, 255, 255, 0) 0px 1px 2px;
  transition: background-color 0.2s, border-color 0.2s, box-shadow 0.2s;
  text-decoration: none;
}

.roomView .endActions :is(button, a):not(:disabled):hover {
  background: var(--hud-hover);
  border-color: rgb(140, 184, 144);
  box-shadow: var(--control-hover-shadow);
}

.roomView .endActions button:disabled {
  background: var(--control-surface);
  color: rgb(32, 37, 31);
  box-shadow: none;
  cursor: default;
}

@media (prefers-reduced-motion: reduce) {
  .roomView .endActions :is(button, a) {
    transition: none;
}
}

@media (max-height: 460px) {
  .resultFan,
  .roomView :is(.resultBand, .resultBandSurface) {
    height: 240px;
}

  .roomView :is(.resultBand, .resultBandSurface) > div {
    top: 60px;
}

  .roomView .resultRate > div {
    top: 120px;
}

  .roomView .resultTitleBand > div {
    top: 165px;
}
}

.resultRank.promoted {
  gap: 10px;
}

.resultRank.promoted #rankChange {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin: 0px;
}

.resultRank.promoted #rankChange strong {
  font-size: 1.35em;
  white-space: nowrap;
}

@media (max-width: 600px), (max-height: 460px) {
  .resultRank.promoted {
    gap: 5px;
}

  .resultRank.promoted #rankChange {
    gap: 2px;
    font-size: 13px;
}

  .resultRank.promoted #rankChange strong {
    font-size: 1.2em;
}
}

.roomView :is(.resultBand, .resultBandSurface)::after {
  translate: 8px 16px;
}

.resultRank.promoted #resultRankOldName,
.resultRank.promoted #resultRankArrow {
  white-space: nowrap;
  flex-shrink: 0;
}

.resultRank.promoted #resultRankOldName {
  font-size: clamp(15px, 2vw, 23px);
}

@media (max-width: 600px), (max-height: 460px) {
  .resultRank.promoted #resultRankOldName {
    font-size: 12px;
}

  .resultRank.promoted #resultRankArrow {
    font-size: 13px;
}

  .roomView :is(.resultBand, .resultBandSurface)::after {
    translate: 5px 11px;
}
}

.resultRank.promoted .promotionHologram {
  font-weight: 900;
}

.roomView :is(.resultBand, .resultBandSurface)::before {
  content: "";
  width: min(var(--result-band-max-width),112vw);
  margin-left: calc(min(var(--result-band-max-width),112vw) / -2);
  clip-path: polygon(7% 41%, 100% -10%, 88% 44%, 0px 60%);
}

.roomView :is(.resultBand, .resultBandSurface)::after {
  background: rgb(0, 0, 0);
  content: "";
  position: absolute;
  z-index: -2;
  left: 50%;
  top: 0px;
  bottom: 0px;
  scale: 1.025 1.04;
  width: min(var(--result-band-max-width),112vw);
  margin-left: calc(min(var(--result-band-max-width),112vw) / -2);
  clip-path: polygon(7% 41%, 100% -10%, 88% 44%, 0px 60%);
}

.roomView .resultRate::before,
.roomView .resultRate::after {
  clip-path: polygon(1% 61%, 94% 44%, 100% 67%, 9% 70%);
}

.roomView .resultTitleBand::before,
.roomView .resultTitleBand::after {
  clip-path: polygon(10% 69%, 100% 68%, 85% 100%, 0px 90%);
}

.roomView :is(.resultBand, .resultBandSurface) > div {
  right: 8px;
  transform-origin: left center;
  text-shadow: rgb(0, 0, 0) 1px 1px 0px, rgb(0, 0, 0) -1px -1px 0px, rgb(0, 0, 0) 3px 4px 0px, rgb(0, 0, 0) 5px 7px 0px;
}

.roomView .resultDialog #resultTitle {
  position: relative;
  transform-origin: center center;
  line-height: 1.3;
  text-shadow: rgb(0, 0, 0) 1px 1px 0px, rgb(0, 0, 0) -1px -1px 0px, rgb(0, 0, 0) 3px 4px 0px, rgb(0, 0, 0) 5px 7px 0px;
  font-size: clamp(34px, 5.5vw, 70px);
  font-weight: 900;
  letter-spacing: -1px;
}

.roomView :is(.resultBand, .resultBandSurface) p {
  overflow-wrap: anywhere;
  margin-right: 0px;
  margin-bottom: 8px;
  font-size: clamp(17px, 2.7vw, 30px);
  font-weight: 800;
}

.roomView .resultRank img {
  width: 76px;
  height: 76px;
  filter: drop-shadow(rgba(0, 0, 0, 0.533) 0px 4px 4px);
}

.resultRank.promoted #resultRankOldIcon {
  opacity: 0.85;
  width: 48px;
  height: 48px;
}

.resultRank.promoted #resultRankIcon {
  width: 94px;
  height: 94px;
}

.resultRank.promoted .promotionHologram {
  translate: 0px -3px;
  text-shadow: none;
  font-family: "Arial Black", "Yu Gothic", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  font-size: 2.7em;
  filter: drop-shadow(rgb(0, 0, 0) 1px 3px 2px) drop-shadow(rgb(215, 255, 255) 0px 0px 7px);
}

@media (max-width: 600px), (max-height: 460px) {
  .roomView .resultDialog #resultTitle {
    font-size: clamp(30px, 7vw, 44px);
}

  .roomView :is(.resultBand, .resultBandSurface) p {
    font-size: clamp(16px, 3.5vw, 21px);
}

  .roomView .resultRank {
    flex-wrap: wrap;
    gap: 5px;
}

  .roomView .resultRank img {
    width: 52px;
    height: 52px;
}

  .resultRank.promoted #resultRankOldIcon {
    width: 32px;
    height: 32px;
}

  .resultRank.promoted #resultRankIcon {
    width: 62px;
    height: 62px;
}

  .resultRank.promoted .promotionHologram {
    translate: 0px -2px;
    font-size: 2.1em;
    margin-left: 4px;
}
}

.roomView .resultDialog .actions {
  box-sizing: border-box;
  border-radius: 4px;
  position: relative;
  z-index: 1;
  pointer-events: auto;
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  width: min(720px, 100% - 16px);
  max-width: calc(100% - 16px);
  padding: 6px;
  margin: 12px auto 0px;
}

.roomView .resultDialog .actions > :is(a, button) {
  flex: 1 1 0px;
  min-width: 0px;
  width: auto;
  max-width: none;
  white-space: nowrap;
  box-sizing: border-box;
  padding: 8px 3px;
  text-align: center;
}

#ratingChange .resultRateFraction {
  font-size: 0.75em;
}

.watchResultActions,
body.watchMode #resultPanel > .actions {
  display: none;
}

body.watchMode .watchResultActions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
  margin: 12px 0px;
}

.watchResultActions .uiAction {
  padding: 11px 17px;
  border-radius: 5px;
  font-weight: 700;
}

body.roomView.watchMode .resultDialog .watchResultActions {
  pointer-events: auto;
}

/* Four result actions remain readable on narrow screens. */
@media (max-width: 600px) {
  .roomView .resultDialog .actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
}
}

/* Background layers remain below all result text, including animated bands. */
.roomView .resultBand { z-index: 10; }
.roomView .resultBand::before,
.roomView .resultBand::after { content: none; }
.roomView .resultBandSurface { pointer-events: none; }

/* Promotion is a board-specific control, not a light action-dialog button. */
.roomView .promotion .actions button {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 88px;
  flex: 1 1 0px;
}
.promotionPiece {
  display: block;
  width: 48px;
  height: 48px;
  object-fit: contain;
}
.promotionPiece.flip { transform: rotate(180deg); }

/* Preserve the replay row's button height; enlarge only stepping targets. */
#replayControls .replayStep {
  min-width: 48px;
  flex-shrink: 0;
}
