.katakati-game-page {
    --board-1: #142b3a;
    --board-2: #071620;
    --board-3: #1f4d62;
    --ink: #dcecf2;
    --panel: rgba(10, 26, 36, .94);
    --panel-soft: rgba(232, 244, 249, .94);
    --panel-line: rgba(156, 206, 226, .32);
    --shadow: rgba(0, 0, 0, .38);
    --red: #e83d3b;
    --red-dark: #8e171a;
    --blue: #1b8eea;
    --blue-dark: #064899;
    --cream: #fff7dd;
    --text-dark: #1a2d35;
    --center-mark: rgba(80,0,35,.38);
    --blue-center-mark: rgba(0,18,104,.46);
  }
.katakati-game-page,
.katakati-game-page *,
.katakati-game-page *::before,
.katakati-game-page *::after { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
.katakati-game-page {
    background:
      radial-gradient(circle at 50% 18%, rgba(92, 150, 171, .24), transparent 34%),
      linear-gradient(120deg, rgba(255,255,255,.05), transparent 30%, rgba(255,255,255,.035) 66%, transparent),
      linear-gradient(160deg, var(--board-2), var(--board-1) 48%, var(--board-3));
    min-height: calc(100vh - var(--header-h));
  }

  .game {
    width: min(100%, 880px);
    min-height: calc(100vh - var(--header-h));
    margin: 0 auto;
    padding: max(10px, env(safe-area-inset-top)) 12px max(10px, env(safe-area-inset-bottom));
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 8px;
  }

  .top-bar,
  .bottom-bar {
    display: grid;
    grid-template-columns: 52px minmax(0, 1fr) 52px;
    gap: 8px;
    align-items: center;
    position: relative;
    z-index: 2;
  }

  .player-panel {
    min-height: 68px;
    border: 1px solid var(--panel-line);
    border-radius: 8px;
    background: var(--panel);
    box-shadow: inset 0 1px rgba(255,255,255,.18), 0 10px 20px var(--shadow);
    color: #fff;
    display: grid;
    grid-template-columns: minmax(0, 1fr) 82px minmax(0, .82fr);
    align-items: center;
    overflow: visible;
  }

  .top-bar .player-panel {
    border-left: 5px solid var(--red);
    transform: rotate(180deg);
  }

  .bottom-bar .player-panel { border-left: 5px solid var(--blue); }

  .player-copy {
    min-width: 0;
    padding: 7px 8px;
    text-align: center;
    text-shadow: 0 1px 1px rgba(0, 0, 0, .28);
  }

  .player-copy.clickable {
    cursor: pointer;
    border-radius: 8px;
    transition: background .12s ease, transform .12s ease;
  }

  .player-copy.clickable:active {
    background: rgba(255, 255, 255, .08);
    transform: translateY(1px);
  }

  .player-copy strong {
    display: block;
    font-size: clamp(17px, 4.2vw, 25px);
    line-height: 1.05;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .player-copy span {
    display: block;
    margin-top: 5px;
    font-size: clamp(11px, 2.8vw, 15px);
    font-weight: 800;
    color: rgba(255, 247, 221, .88);
    letter-spacing: 0;
  }

  .avatar {
    width: 78px;
    height: 78px;
    margin: -9px auto;
    border-radius: 50%;
    border: 4px solid rgba(242, 248, 250, .68);
    background:
      radial-gradient(circle at 32% 28%, rgba(255,255,255,.92) 0 10%, rgba(255,255,255,.22) 11% 20%, transparent 21%),
      radial-gradient(circle at 54% 58%, var(--red) 0 47%, var(--red-dark) 68% 100%);
    display: grid;
    place-items: center;
    box-shadow: inset 0 -9px 13px rgba(0, 0, 0, .24), inset 0 6px 10px rgba(255, 255, 255, .18), 0 8px 18px rgba(0, 0, 0, .26);
    font-size: 0;
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
  }

  .avatar::before {
    content: "";
    width: 52px;
    height: 52px;
    border-radius: 50%;
    background:
      radial-gradient(circle at 34% 24%, rgba(255,255,255,.9) 0 10%, rgba(255,255,255,.18) 11% 22%, transparent 23%),
      radial-gradient(circle at 55% 60%, var(--red) 0 52%, var(--red-dark) 74% 100%);
    box-shadow: inset 0 -7px 9px rgba(0,0,0,.25), 0 5px 8px rgba(0,0,0,.22);
  }

  .bottom-bar .avatar {
    border-color: rgba(232, 247, 255, .78);
    background:
      radial-gradient(circle at 32% 28%, rgba(255,255,255,.92) 0 10%, rgba(255,255,255,.22) 11% 20%, transparent 21%),
      radial-gradient(circle at 54% 58%, var(--blue) 0 47%, var(--blue-dark) 68% 100%);
  }

  .bottom-bar .avatar::before {
    background:
      radial-gradient(circle at 34% 24%, rgba(255,255,255,.9) 0 10%, rgba(255,255,255,.18) 11% 22%, transparent 23%),
      radial-gradient(circle at 55% 60%, var(--blue) 0 52%, var(--blue-dark) 74% 100%);
  }

  .round-btn {
    width: 52px;
    height: 52px;
    border: 0;
    border-radius: 50%;
    background: linear-gradient(180deg, rgba(240, 249, 252, .96), rgba(175, 207, 217, .92));
    box-shadow: inset 0 -3px 6px rgba(0,0,0,.16), 0 8px 16px var(--shadow);
    color: #123140;
    font-size: 28px;
    font-weight: 900;
    display: grid;
    place-items: center;
    transition: transform .12s ease, filter .12s ease;
  }
.katakati-game-page button {
    font-family: inherit;
    user-select: none;
  }
.katakati-game-page button:active,
  .avatar:active {
    transform: translateY(1px) scale(.98);
  }
.katakati-game-page button:focus-visible,
  .avatar:focus-visible {
    outline: 3px solid rgba(255, 242, 122, .95);
    outline-offset: 3px;
  }

  .board-area {
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 0;
  }

  .board-shell {
    width: min(100%, calc((100vh - 176px) * .70));
    width: min(100%, calc((100dvh - 176px) * .70));
    max-width: 820px;
    min-width: min(320px, 100%);
    aspect-ratio: 920 / 1360;
    position: relative;
    display: grid;
    grid-template-rows: 44px 1fr 44px;
    align-items: center;
  }

  .board-shell::before {
    content: "";
    position: absolute;
    inset: 30px 12px;
    border-radius: 8px;
    background:
      radial-gradient(circle at 50% 28%, rgba(255,255,255,.08), transparent 42%),
      linear-gradient(180deg, rgba(255, 255, 255, .06), rgba(0, 0, 0, .12));
    border: 1px solid rgba(206, 232, 242, .2);
    box-shadow: inset 0 0 0 3px rgba(255,255,255,.05), 0 12px 24px rgba(0, 0, 0, .2);
    pointer-events: none;
  }

  #board {
    width: 100%;
    height: 100%;
    display: block;
    position: relative;
    z-index: 1;
    filter: drop-shadow(0 8px 7px rgba(27, 15, 8, .2));
  }

  .board-line {
    stroke: var(--ink);
    stroke-width: 7;
    stroke-linecap: round;
  }

  .target {
    fill: rgba(255, 241, 97, .96);
    stroke: rgba(71, 42, 27, .72);
    stroke-width: 5;
    opacity: 0;
    transform-box: fill-box;
    transform-origin: center;
    animation: pulse .85s ease-in-out infinite alternate;
  }

  .target.show { opacity: 1; }
  .target.capture { fill: rgba(255, 89, 74, .96); }

  @keyframes pulse {
    from { transform: scale(.76); }
    to { transform: scale(1.04); }
  }

  .piece {
    cursor: pointer;
    filter: drop-shadow(0 5px 3px rgba(24, 12, 7, .36));
  }

  .piece-core { stroke-width: 5; }
  .piece.red .piece-core { fill: var(--red); stroke: var(--red-dark); }
  .piece.blue .piece-core { fill: var(--blue); stroke: var(--blue-dark); }
  .piece-ring { fill: none; stroke: rgba(255,255,255,.35); stroke-width: 4; }
  .piece-center {
    fill: rgba(255,255,255,.16);
    stroke: var(--center-mark);
    stroke-width: 6;
  }
  .piece-center-dot { fill: var(--center-mark); }
  .piece.blue .piece-center { stroke: var(--blue-center-mark); }
  .piece.blue .piece-center-dot { fill: var(--blue-center-mark); }

  .move-shadow {
    opacity: .28;
    pointer-events: none;
  }

  .move-shadow .piece-core {
    stroke-width: 5;
    stroke-dasharray: 8 7;
  }

  .piece.selected .piece-core {
    stroke: #fff469;
    stroke-width: 9;
  }

  .piece.captured-preview .piece-core {
    stroke: #ffef78;
    stroke-width: 9;
  }

  .status-card {
    justify-self: center;
    min-width: 190px;
    max-width: min(78vw, 380px);
    border-radius: 8px;
    background: var(--panel-soft);
    color: var(--text-dark);
    border: 1px solid rgba(91, 57, 31, .16);
    padding: 9px 13px;
    text-align: center;
    font-weight: 900;
    font-size: clamp(12px, 3vw, 16px);
    box-shadow: 0 8px 16px rgba(35, 18, 9, .18);
    z-index: 3;
    pointer-events: none;
    transition: opacity .16s ease, transform .16s ease;
  }

  .status-card.top {
    grid-row: 1;
  }

  .status-card.bottom {
    grid-row: 3;
  }

  .status-card.hidden {
    opacity: 0;
    transform: scale(.98);
  }

  .controls {
    display: grid;
    grid-template-columns: repeat(6, minmax(0, 1fr));
    gap: 7px;
    margin-top: 8px;
  }

  .control-btn {
    min-width: 0;
    min-height: 46px;
    border: 1px solid rgba(255, 236, 188, .28);
    border-radius: 8px;
    background: rgba(255, 247, 222, .9);
    color: #2f2820;
    padding: 9px 6px;
    font-size: clamp(11px, 2.7vw, 14px);
    font-weight: 900;
    line-height: 1.05;
    white-space: normal;
    overflow-wrap: anywhere;
    box-shadow: inset 0 1px rgba(255,255,255,.5), 0 7px 14px rgba(31, 17, 9, .18);
    transition: transform .12s ease, background .12s ease, color .12s ease, border-color .12s ease;
  }

  .control-btn.primary {
    background: linear-gradient(180deg, #335f50, #1d4038);
    color: #fff;
    border-color: rgba(204, 238, 226, .24);
  }

  .control-btn.active {
    background: linear-gradient(180deg, #1f86d2, #0d4f8d);
    color: #fff;
    border-color: rgba(209, 236, 255, .5);
  }

  .control-btn.muted {
    background: rgba(70, 70, 70, .82);
    color: rgba(255,255,255,.88);
  }

  .control-btn:disabled {
    opacity: .55;
    filter: grayscale(.3);
    transform: none;
  }

  .overlay {
    position: fixed;
    inset: 0;
    display: none;
    place-items: center;
    background: rgba(16, 18, 16, .64);
    backdrop-filter: blur(3px);
    z-index: 20;
    padding: 18px;
  }

  .overlay.show { display: grid; }

  .dialog {
    width: min(92vw, 420px);
    border-radius: 8px;
    background: #fff8e6;
    color: #38251d;
    padding: 24px;
    border: 1px solid rgba(83, 52, 28, .16);
    box-shadow: 0 18px 40px rgba(14, 14, 12, .38);
    text-align: center;
  }

  .overlay.opponent-side .dialog {
    transform: rotate(180deg);
  }

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

  .dialog-body {
    margin: 8px 0 18px;
    color: #604335;
    line-height: 1.45;
    font-weight: 700;
  }

  .dialog-body p {
    margin: 0;
  }

  .dialog input {
    width: 100%;
    margin-top: 12px;
    border: 1px solid rgba(83, 52, 28, .24);
    border-radius: 8px;
    background: #fff;
    color: #2f2820;
    padding: 13px 12px;
    font: inherit;
    font-weight: 900;
    text-align: center;
  }

  .dialog-actions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .dialog-actions.two {
    grid-template-columns: 1fr 1fr;
  }

  .dialog button {
    width: 100%;
    border: 0;
    border-radius: 8px;
    background: #254d43;
    color: #fff;
    padding: 13px;
    font-size: 17px;
    font-weight: 900;
  }

  .dialog button.secondary {
    background: rgba(81, 69, 58, .16);
    color: #38251d;
  }

  .scoreboard {
    display: grid;
    gap: 10px;
    margin-top: 14px;
    text-align: left;
  }

  .score-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 52px 64px;
    gap: 8px;
    align-items: center;
    border-radius: 8px;
    background: rgba(255, 255, 255, .58);
    border: 1px solid rgba(83, 52, 28, .12);
    padding: 10px;
  }

  .score-row strong,
  .score-row span {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .score-row .wins {
    text-align: center;
    font-size: 22px;
    color: #254d43;
  }

  .score-row .guti {
    text-align: right;
    color: #604335;
    font-size: 13px;
  }

  .score-note {
    margin-top: 10px;
    color: #6a5145;
    font-size: 13px;
    text-align: center;
  }

  @media (max-width: 380px) {
    .game { padding-left: 9px; padding-right: 9px; }
    .top-bar,
    .bottom-bar { grid-template-columns: 46px minmax(0, 1fr) 46px; gap: 6px; }
    .round-btn { width: 46px; height: 46px; font-size: 24px; }
    .avatar { width: 68px; height: 68px; font-size: 30px; }
    .player-panel { grid-template-columns: minmax(0, 1fr) 70px minmax(0, .8fr); }
    .controls { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  }

  @media (max-height: 740px) {
    .player-panel { min-height: 58px; }
    .avatar { width: 68px; height: 68px; font-size: 30px; }
    .round-btn { width: 46px; height: 46px; font-size: 24px; }
    .board-shell {
      grid-template-rows: 38px 1fr 38px;
      width: min(100%, calc((100vh - 152px) * .70));
      width: min(100%, calc((100dvh - 152px) * .70));
    }
    .status-card { padding: 8px 12px; }
    .control-btn { min-height: 40px; padding: 8px 4px; }
  }
