  * { margin: 0; padding: 0; box-sizing: border-box; }

  body {
    font-family: 'Noto Serif', Georgia, serif;
    background: #f5f0e8;
    color: #2c2c2c;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 12px 16px;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    overflow-x: hidden;
  }

  /* ============ SPLASH ============ */
  #splash {
    position: fixed;
    inset: 0;
    z-index: 200;
    background: #f5f0e8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s, visibility 0.8s;
    padding: 16px;
  }
  #splash.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

  .floater {
    position: absolute;
    font-size: 1.2rem;
    opacity: 0.06;
    animation: floatUp linear infinite;
    pointer-events: none;
  }
  @keyframes floatUp {
    0%   { transform: translateY(110vh) rotate(0deg); }
    100% { transform: translateY(-20vh) rotate(720deg); }
  }

  /* Ink & Seal stamp */
  .splash-seal {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 52px;
    height: 52px;
    border: 2.5px solid #c0392b;
    border-radius: 4px;
    transform: rotate(-8deg);
    font-family: 'Noto Serif SC', serif;
    font-size: 1rem;
    font-weight: 700;
    color: #c0392b;
    line-height: 1.15;
    letter-spacing: 1px;
    text-align: center;
    margin-bottom: 14px;
    position: relative;
    z-index: 1;
    opacity: 0;
    animation: stampIn 0.5s cubic-bezier(0.22, 1, 0.36, 1) 0.2s forwards;
  }
  @keyframes stampIn {
    0%   { opacity: 0; transform: rotate(-8deg) scale(1.4); }
    65%  { opacity: 1; transform: rotate(-8deg) scale(0.93); }
    100% { opacity: 1; transform: rotate(-8deg) scale(1); }
  }

  .splash-cn {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: clamp(2rem, 10vw, 3.4rem);
    font-weight: 900;
    color: #2c2c2c;
    letter-spacing: 4px;
    text-transform: uppercase;
    white-space: nowrap;
    opacity: 0;
    animation: brushInArena 1.1s ease-out 0.7s forwards;
    position: relative;
    z-index: 1;
  }
  @keyframes brushIn {
    0% { opacity: 0; transform: translateY(10px); letter-spacing: 20px; }
    100% { opacity: 1; transform: translateY(0); letter-spacing: 8px; }
  }
  @keyframes brushInArena {
    0%   { opacity: 0; transform: translateY(10px); letter-spacing: 14px; }
    100% { opacity: 1; transform: translateY(0);  letter-spacing: 4px; }
  }

  .splash-en {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.95rem;
    color: #8b6914;
    letter-spacing: 8px;
    margin-top: 4px;
    opacity: 0;
    animation: fadeIn 0.8s ease-out 1.1s forwards;
    position: relative;
    z-index: 1;
  }
  @keyframes fadeIn {
    0% { opacity: 0; }
    100% { opacity: 1; }
  }

  .splash-line {
    width: 60px;
    height: 1px;
    background: linear-gradient(90deg, transparent, #c0392b66, transparent);
    margin: 18px 0;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 1.4s forwards;
    position: relative;
    z-index: 1;
  }

  .splash-play {
    padding: 12px 48px;
    border: 1.5px solid #2c2c2c;
    border-radius: 4px;
    font-family: 'Noto Serif', serif;
    font-size: 1rem;
    letter-spacing: 6px;
    text-transform: uppercase;
    color: #2c2c2c;
    background: transparent;
    cursor: pointer;
    position: relative;
    z-index: 1;
    opacity: 0;
    animation: fadeIn 0.6s ease-out 1.6s forwards;
    transition: background 0.3s, color 0.3s;
  }
  .splash-play:hover { background: #2c2c2c; color: #f5f0e8; }

  /* ===== HOME SCREEN CARDS ===== */
  .splash-cards {
    display: flex;
    flex-direction: column;
    gap: 9px;
    width: 100%;
    max-width: 340px;
    padding: 0 24px;
    position: relative;
    z-index: 1;
    margin-bottom: 18px;
  }
  .splash-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    background: rgba(255,255,255,0.75);
    border: 1.5px solid #d4ccc0;
    border-radius: 3px;
    cursor: pointer;
    text-align: left;
    transition: border-color 0.2s, background 0.2s;
    width: 100%;
    opacity: 0;
    animation: fadeIn 0.5s ease-out forwards;
  }
  .splash-card:nth-child(1) { animation-delay: 1.7s; }
  .splash-card:nth-child(2) { animation-delay: 1.85s; }
  .splash-card:nth-child(3) { animation-delay: 2.0s; }
  .splash-card:nth-child(4) { animation-delay: 2.15s; }
  .splash-card:not(.splash-card-soon):hover { border-color: #2c2c2c; background: #fff; }
  .splash-card-soon { cursor: default; }
  .splash-card-icon {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.85rem;
    font-weight: 700;
    color: #2c2c2c;
    border: 1.5px solid #2c2c2c;
    width: 30px;
    height: 30px;
    min-width: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 2px;
  }
  .splash-card-soon .splash-card-icon { border-color: #bbb; color: #bbb; }
  .splash-card-body { flex: 1; }
  .splash-card-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.88rem;
    font-weight: 700;
    color: #2c2c2c;
    letter-spacing: 0.5px;
  }
  .splash-card-sub {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.72rem;
    color: #999;
    margin-top: 2px;
  }
  .splash-card-soon .splash-card-title { color: #bbb; }
  .splash-card-soon .splash-card-sub { color: #bbb; }
  .splash-card-arrow { font-size: 1.1rem; color: #c8bda8; flex-shrink: 0; }
  .splash-soon-badge {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.58rem;
    letter-spacing: 1.5px;
    color: #c8a96e;
    border: 1px solid #c8a96e;
    padding: 2px 6px;
    border-radius: 2px;
    flex-shrink: 0;
  }
  .splash-footer-links {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.72rem;
    color: #bbb;
    letter-spacing: 1px;
    text-align: center;
    padding: 0 20px;
    line-height: 2;
    position: relative;
    z-index: 1;
    opacity: 0;
    animation: fadeIn 0.5s ease-out 2.35s forwards;
  }
  .splash-footer-links a { color: #8b6914; text-decoration: none; }
  .splash-footer-links a:hover { text-decoration: underline; }

  /* ===== ONLINE SUB-SCREEN ===== */
  #onlineScreen {
    position: fixed;
    inset: 0;
    z-index: 210;
    background: #f5f0e8;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
    padding: 32px 0;
    transition: opacity 0.35s ease, visibility 0.35s ease;
  }
  #onlineScreen.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .online-back {
    position: absolute;
    top: 20px;
    left: 20px;
    background: transparent;
    border: none;
    color: #8b6914;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.82rem;
    letter-spacing: 1px;
    cursor: pointer;
    padding: 8px;
    transition: color 0.2s;
  }
  .online-back:hover { color: #2c2c2c; }
  .online-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.25rem;
    font-weight: 900;
    color: #2c2c2c;
    letter-spacing: 3px;
    margin-bottom: 4px;
    position: relative;
    z-index: 1;
  }
  .online-subtitle {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.78rem;
    color: #aaa;
    letter-spacing: 2px;
    margin-bottom: 24px;
    position: relative;
    z-index: 1;
  }
  .online-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 13px 16px;
    background: rgba(255,255,255,0.75);
    border: 1.5px solid #d4ccc0;
    border-radius: 3px;
    cursor: default;
    text-align: left;
    width: 100%;
    opacity: 1;
  }
  /* ===== ONLINE UI ADDITIONS ===== */
  .online-user-row {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.78rem;
    color: #8b6914;
    letter-spacing: 1px;
    min-height: 20px;
    margin-bottom: 6px;
  }
  .online-elo-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 14px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.78rem;
    color: #888;
    letter-spacing: 1px;
  }
  .online-elo-val {
    font-weight: 700;
    color: #2c2c2c;
    font-size: 1rem;
  }
  /* Matchmaking overlay */
  #matchmakingOverlay {
    position: fixed; inset: 0; z-index: 215;
    background: #f5f0e8;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.3s, visibility 0.3s;
  }
  #matchmakingOverlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .matchmaking-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 10px; padding: 40px 24px; max-width: 320px; width: 100%; text-align: center;
  }
  .matchmaking-spinner {
    display: flex; gap: 8px; margin-bottom: 4px;
  }
  .matchmaking-spinner span {
    width: 10px; height: 10px; border-radius: 50%;
    background: #c8a96e;
    animation: mqPulse 1.2s ease-in-out infinite;
  }
  .matchmaking-spinner span:nth-child(2) { animation-delay: 0.2s; }
  .matchmaking-spinner span:nth-child(3) { animation-delay: 0.4s; }
  @keyframes mqPulse {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
  }
  .matchmaking-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.1rem; font-weight: 700;
    letter-spacing: 2px; color: #2c2c2c;
  }
  .matchmaking-timer {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 2.2rem; font-weight: 700;
    color: #8b6914; letter-spacing: 2px;
    line-height: 1;
  }
  .matchmaking-sub {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; color: #888;
    letter-spacing: 0.5px;
  }
  .matchmaking-bot-offer {
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    margin-top: 6px; padding: 16px 20px;
    background: rgba(255,255,255,0.7);
    border: 1.5px solid #d4ccc0; border-radius: 4px;
  }
  .matchmaking-bot-offer.hidden { display: none; }
  .matchmaking-bot-msg {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.82rem; color: #555; letter-spacing: 0.5px;
  }
  .matchmaking-bot-btn {
    background: #2c2c2c; color: #f5f0e8;
    border: none; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; letter-spacing: 1px;
    padding: 9px 22px; cursor: pointer;
    transition: background 0.2s;
  }
  .matchmaking-bot-btn:hover { background: #444; }
  .matchmaking-cancel {
    margin-top: 6px;
    background: transparent; border: 1.5px solid #c8bda8;
    border-radius: 3px; color: #888;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.78rem; letter-spacing: 1px;
    padding: 8px 24px; cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
  }
  .matchmaking-cancel:hover { color: #2c2c2c; border-color: #2c2c2c; }
  /* Invite room overlay */
  #inviteRoomOverlay {
    position: fixed; inset: 0; z-index: 215;
    background: #f5f0e8;
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.3s, visibility 0.3s;
  }
  #inviteRoomOverlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .invite-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 14px; padding: 40px 24px; max-width: 360px; width: 100%; text-align: center;
  }
  .invite-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.1rem; font-weight: 700;
    letter-spacing: 2px; color: #2c2c2c;
  }
  .invite-sub {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; color: #888; letter-spacing: 0.5px;
  }
  .invite-link-box {
    display: flex; align-items: center; gap: 8px;
    background: #fff; border: 1.5px solid #d4ccc0;
    border-radius: 3px; padding: 10px 12px;
    width: 100%; box-sizing: border-box;
  }
  .invite-link-text {
    flex: 1; font-family: monospace; font-size: 0.78rem;
    color: #555; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .invite-copy-btn {
    background: #2c2c2c; color: #f5f0e8;
    border: none; border-radius: 2px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.72rem; letter-spacing: 1px;
    padding: 5px 12px; cursor: pointer;
    flex-shrink: 0; transition: background 0.2s;
  }
  .invite-copy-btn:hover { background: #444; }
  .invite-copy-btn.copied { background: #5a8a5a; }
  .invite-waiting {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    margin-top: 4px;
  }
  .invite-waiting-text {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; color: #888; letter-spacing: 0.5px;
  }
  /* Account prompt overlay */
  #accountPromptOverlay {
    position: fixed; inset: 0; z-index: 300;
    background: rgba(245,240,232,0.97);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.3s, visibility 0.3s;
  }
  #accountPromptOverlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .account-prompt-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 12px; padding: 40px 28px; max-width: 340px; width: 100%;
    text-align: center;
  }
  .account-prompt-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.15rem; font-weight: 700;
    letter-spacing: 2px; color: #2c2c2c;
  }
  .account-prompt-rating {
    display: flex; flex-direction: column; align-items: center; gap: 2px;
    padding: 12px 28px;
    background: rgba(255,255,255,0.8);
    border: 1.5px solid #d4ccc0; border-radius: 4px;
  }
  .account-prompt-elo-label {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.68rem; color: #888; letter-spacing: 2px; text-transform: uppercase;
  }
  .account-prompt-elo-val {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 2rem; font-weight: 700; color: #8b6914;
  }
  .account-prompt-sub {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; color: #666; letter-spacing: 0.5px; line-height: 1.5;
  }
  .account-prompt-google {
    display: flex; align-items: center; justify-content: center; gap: 10px;
    width: 100%; padding: 11px 20px;
    background: #fff; border: 1.5px solid #d4ccc0; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.85rem; letter-spacing: 0.5px; color: #2c2c2c;
    cursor: pointer; transition: border-color 0.2s, background 0.2s;
  }
  .account-prompt-google:hover { border-color: #2c2c2c; background: #f9f5ef; }
  .account-prompt-divider {
    width: 100%; display: flex; align-items: center; gap: 10px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.72rem; color: #bbb;
  }
  .account-prompt-divider::before, .account-prompt-divider::after {
    content: ''; flex: 1; height: 1px; background: #d4ccc0;
  }
  .account-prompt-fields {
    display: flex; flex-direction: column; gap: 8px; width: 100%;
  }
  .account-prompt-input {
    width: 100%; box-sizing: border-box;
    padding: 10px 12px;
    background: #fff; border: 1.5px solid #d4ccc0; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.85rem; color: #2c2c2c;
    outline: none; transition: border-color 0.2s;
  }
  .account-prompt-input:focus { border-color: #8b6914; }
  .account-prompt-submit {
    width: 100%; padding: 11px;
    background: #2c2c2c; color: #f5f0e8;
    border: none; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.85rem; letter-spacing: 1px;
    cursor: pointer; transition: background 0.2s;
  }
  .account-prompt-submit:hover { background: #444; }
  .account-prompt-later {
    background: transparent; border: none;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.75rem; color: #aaa; letter-spacing: 0.5px;
    cursor: pointer; transition: color 0.2s;
    padding: 4px 8px;
  }
  .account-prompt-later:hover { color: #666; }
  /* Username picker */
  #usernamePickerOverlay {
    position: fixed; inset: 0; z-index: 310;
    background: rgba(245,240,232,0.97);
    display: flex; align-items: center; justify-content: center;
    transition: opacity 0.3s, visibility 0.3s;
  }
  #usernamePickerOverlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }
  .username-picker-inner {
    display: flex; flex-direction: column; align-items: center;
    gap: 14px; padding: 40px 28px; max-width: 320px; width: 100%; text-align: center;
  }
  .username-picker-title {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.1rem; font-weight: 700;
    letter-spacing: 2px; color: #2c2c2c;
  }
  .username-picker-sub {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem; color: #888; letter-spacing: 0.5px;
  }
  .username-picker-input {
    width: 100%; box-sizing: border-box;
    padding: 11px 14px; text-align: center;
    background: #fff; border: 1.5px solid #d4ccc0; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1rem; color: #2c2c2c; letter-spacing: 1px;
    outline: none; transition: border-color 0.2s;
  }
  .username-picker-input:focus { border-color: #8b6914; }
  .username-picker-error {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.75rem; color: #c0392b; letter-spacing: 0.5px;
  }
  .username-picker-error.hidden { display: none; }
  .username-picker-confirm {
    width: 100%; padding: 12px;
    background: #2c2c2c; color: #f5f0e8;
    border: none; border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.88rem; letter-spacing: 1.5px;
    cursor: pointer; transition: background 0.2s;
  }
  .username-picker-confirm:hover { background: #444; }

  /* ===== GAME HEADER HOME BUTTON ===== */
  .btn-home {
    display: block;
    margin: 14px auto 0;
    background: transparent;
    border: 1.5px solid #c8bda8;
    border-radius: 4px;
    color: #8b7355;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.78rem;
    letter-spacing: 1px;
    cursor: pointer;
    padding: 7px 22px;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
  }
  .btn-home:hover { background: #e0d8cc; color: #2c2c2c; border-color: #8b7355; }
  .game-header-home {
    position: absolute; left: 0; margin: 0;
    padding: 4px 10px; font-size: 0.75rem; letter-spacing: 0.5px;
  }
  .game-header-right {
    /* Pinned to the viewport corner so icons sit exactly where they do on the splash/online/bot-select screens */
    position: fixed; top: 12px; right: 14px; z-index: 5;
    display: flex; align-items: center; gap: 6px;
  }

  .game-header-right .btn-settings {
    position: static; transform: none; top: auto; right: auto;
  }
  /* Hide home button in VS-AI mode (no special body class) */
  body:not(.bot-mode):not(.pvp-mode):not(.daily-mode) #btnGoHome { display: none !important; }

  .mode-label {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.62rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #8b7355;
    text-align: center;
    margin-bottom: 3px;
    min-height: 1em;
  }
  body.daily-mode .mode-label { display: none; }

  /* ============ GAME ============ */
  #game {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
  }

  .game-header {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    margin-bottom: 6px;
    position: relative;
  }
  .game-title-cn {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: #2c2c2c;
    letter-spacing: 4px;
    text-transform: uppercase;
  }
  .game-title-en {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.65rem;
    color: #8b6914;
    letter-spacing: 5px;
    margin-top: 1px;
    text-align: center;
  }
  .game-title-wrap { text-align: center; }

  .btn-settings {
    /* Matches .splash-settings-btn — one square icon-button style everywhere */
    background: none;
    border: 1px solid #d4ccc0;
    border-radius: 2px;
    width: 30px;
    height: 30px;
    padding: 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #8b7355;
    transition: all 0.2s;
  }
  .btn-settings:hover { border-color: #2c2c2c; color: #2c2c2c; }


  .status {
    font-family: 'Noto Serif SC', serif;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    min-height: 1.3em;
    transition: color 0.3s;
    color: #555;
  }
  .status.win { color: #2c2c2c; font-weight: 700; }
  .status.lose { color: #c23b22; }
  .status.draw { color: #8b6914; }

  /* ============ BOARD ============ */
  .board {
    display: grid;
    grid-template-columns: repeat(15, 1fr);
    grid-template-rows: repeat(15, 1fr);
    width: min(400px, 94vw);
    aspect-ratio: 1;
    flex-shrink: 0;
    margin-bottom: 10px;
    background: #d4a456;
    border-radius: 4px;
    box-shadow: 0 2px 16px #00000018, inset 0 1px 0 #e8c47a, inset 0 -1px 0 #b8883a;
    padding: 8px;
    position: relative;
  }
  .cell {
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    position: relative;
    background: transparent;
    transition: background 0.1s;
  }
  .cell:hover:not(.disabled) { background: #00000010; border-radius: 50%; }
  .cell.disabled { cursor: default; pointer-events: none; }
  /* Grid lines drawn through intersection centers */
  .cell::before {
    content: '';
    position: absolute;
    left: 0; right: 0;
    top: calc(50% - 0.5px);
    height: 1px;
    background: #1a1a1a55;
    pointer-events: none;
    z-index: 0;
  }
  .cell::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: calc(50% - 0.5px);
    width: 1px;
    background: #1a1a1a55;
    pointer-events: none;
    z-index: 0;
  }
  /* Clip lines at board edges */
  .cell.edge-left::before  { left: 50%; }
  .cell.edge-right::before { right: 50%; }
  .cell.edge-top::after    { top: 50%; }
  .cell.edge-bottom::after { bottom: 50%; }
  /* Star points (hoshi) */
  .star-point {
    position: absolute;
    width: 6px; height: 6px;
    border-radius: 50%;
    background: #1a1a1a99;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 1;
  }

  /* Stones */
  .stone {
    width: 82%;
    height: 82%;
    border-radius: 50%;
    animation: stonePlace 0.3s cubic-bezier(0.22, 1, 0.36, 1);
    position: relative;
    z-index: 2;
  }
  @keyframes stonePlace {
    0% { transform: translateY(-8px) scale(0.7); opacity: 0; }
    60% { transform: translateY(1px) scale(1.02); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
  }
  @keyframes stoneRestore {
    0%   { transform: scale(0.3); opacity: 0; }
    100% { transform: scale(1);   opacity: 1; }
  }
  .stone.black {
    background: radial-gradient(circle at 35% 30%, #555, #1a1a1a 60%, #000);
    box-shadow: 1px 2px 4px #00000044;
  }
  .stone.white {
    background: radial-gradient(circle at 35% 30%, #fff, #ece8e0 50%, #d8d4cc);
    border: 1px solid #00000022;
    box-shadow: 1px 2px 4px #00000022;
  }

  .cell.win-cell {
    background: #8b691422;
  }
  .cell.win-cell .stone { box-shadow: 0 0 10px #8b691466, 1px 2px 4px #00000033; }

  /* Buttons */
  .actions {
    display: flex;
    gap: 10px;
  }
  .actions button {
    padding: 8px 20px;
    border: 1.5px solid #c8bda8;
    border-radius: 4px;
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    color: #555;
  }
  .actions button:active { transform: scale(0.97); }
  .btn-new { background: #2c2c2c; color: #f5f0e8; border-color: #2c2c2c; }
  .btn-new:hover { background: #444; }
  .btn-stats:hover { border-color: #2c2c2c; color: #2c2c2c; }
  .btn-undo:not(:disabled):hover { border-color: #8b6914; color: #8b6914; }
  .btn-undo:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
  .btn-hint:not(:disabled):hover { border-color: #c8a96e; color: #8b6914; }
  .btn-hint:disabled { opacity: 0.3; cursor: default; pointer-events: none; }
  @keyframes hintGhostPulse {
    0%, 100% { opacity: 0.45; transform: scale(1); }
    50%       { opacity: 0.15; transform: scale(0.88); }
  }
  .hint-ghost {
    animation: hintGhostPulse 0.8s ease-in-out infinite !important;
    pointer-events: none;
  }
  .difficulty-start-btn {
    padding: 5px 14px;
    border: 1.5px solid #c8bda8;
    border-radius: 4px;
    background: transparent;
    color: #8b7355;
    font-family: 'Noto Serif', serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s;
  }
  .difficulty-start-btn.active { border-color: #2c2c2c; color: #2c2c2c; background: #2c2c2c0a; }
  .difficulty-start-btn:hover { border-color: #2c2c2c; }
  .difficulty-start-btn.dimmed { opacity: 0.35; pointer-events: none; }

  /* ===== TURN OVERLAY ===== */
  .turn-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(20,16,12,0.92);
    z-index: 200;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    user-select: none;
  }
  .turn-overlay.active { display: flex; animation: turnBgIn 0.25s ease; }
  .turn-overlay.dismissing { animation: turnBgOut 0.3s ease forwards; }
  .turn-card { text-align: center; animation: turnCardIn 0.35s cubic-bezier(0.34,1.56,0.64,1); }
  .turn-overlay.dismissing .turn-card { animation: turnCardOut 0.3s ease forwards; }
  .turn-stone-lg { font-size: 4rem; display: block; margin-bottom: 16px; }
  .turn-player-name {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.9rem;
    font-weight: 900;
    color: #f5f0e8;
    letter-spacing: 4px;
    margin-bottom: 6px;
  }
  .turn-your-move {
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    color: #c8a96e;
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-bottom: 40px;
  }
  .turn-tap-hint {
    font-family: 'Noto Serif', serif;
    font-size: 0.72rem;
    color: rgba(245,240,232,0.3);
    letter-spacing: 2px;
  }
  @keyframes turnBgIn  { from { opacity:0; } to { opacity:1; } }
  @keyframes turnBgOut { from { opacity:1; } to { opacity:0; } }
  @keyframes turnCardIn  { from { opacity:0; transform:translateY(28px) scale(0.9); } to { opacity:1; transform:translateY(0) scale(1); } }
  @keyframes turnCardOut { from { opacity:1; transform:scale(1); } to { opacity:0; transform:scale(0.94); } }

  /* ===== PVP MODE UI VISIBILITY ===== */
  /* Online games: New Game / Undo would desync from the server */
  body.online-mode .actions { display: none !important; }
  body.review-mode #newGame,
  body.review-mode #undoBtn,
  body.review-mode .game-header-right { display: none !important; }

  /* ============ MODALS ============ */
  #confirmOverlay { z-index: 500; }
  #settingsOverlay { z-index: 250; }
  .modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 300;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .modal-overlay.open { display: flex; }
  .modal {
    background: #f5f0e8;
    border-radius: 8px;
    padding: 24px;
    width: min(380px, 94vw);
    max-height: 80dvh;
    overflow-y: auto;
    position: relative;
    color: #2c2c2c;
    box-shadow: 0 8px 40px #00000022;
    border: 1px solid #d4c9b8;
  }
  .modal h2 {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.1rem;
    margin-bottom: 16px;
    text-align: center;
    color: #2c2c2c;
  }
  .modal-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    color: #999;
    font-size: 1.3rem;
    cursor: pointer;
    line-height: 1;
  }
  .modal-close:hover { color: #2c2c2c; }

  /* Stats table */
  .stats-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 4px;
  }
  .stats-table th {
    font-size: 0.7rem;
    font-weight: 700;
    color: #8b6914;
    text-align: center;
    padding: 0 2px 10px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
  }
  .stats-table th:first-child { text-align: left; visibility: hidden; }
  .stats-table td {
    text-align: center;
    padding: 8px 2px;
    border-top: 1px solid #e0d8cc;
    font-size: 0.82rem;
    font-weight: 600;
    color: #2c2c2c;
  }
  .stats-table td:first-child {
    text-align: left;
    color: #8b7355;
    font-weight: 400;
    font-size: 0.78rem;
  }
  .stats-table .col-total { color: #8b6914; }
  .stats-actions {
    display: flex;
    gap: 10px;
    margin-top: 16px;
    justify-content: center;
  }
  .stats-actions button {
    padding: 7px 18px;
    border-radius: 4px;
    font-family: 'Noto Serif', serif;
    font-size: 0.8rem;
    cursor: pointer;
    border: 1.5px solid #c8bda8;
    background: transparent;
    color: #555;
  }
  .btn-stats-reset { border-color: #c23b2244; color: #c23b22; }
  .btn-stats-reset:hover { background: #c23b2211; }
  .btn-stats-close { background: #2c2c2c; color: #f5f0e8; border-color: #2c2c2c; }
  /* Stats tabs */
  .stats-tabs {
    display: flex;
    gap: 0;
    margin-bottom: 16px;
    border-bottom: 2px solid #e0d8cc;
  }
  .stats-tab-btn {
    flex: 1;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    padding: 8px 0;
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    font-weight: 600;
    color: #8b7355;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
  }
  .stats-tab-btn.active { color: #2c2c2c; border-bottom-color: #2c2c2c; }
  .stats-tab-btn:hover:not(.active) { color: #4a3b2a; }
  /* Ranked stats rating display */
  .ranked-elo-display {
    text-align: center;
    margin-bottom: 18px;
  }
  .ranked-elo-number {
    font-size: 2.4rem;
    font-weight: 900;
    color: #2c2c2c;
    line-height: 1;
  }
  .ranked-elo-label {
    font-size: 0.68rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    color: #999;
    margin-top: 2px;
  }
  .ranked-elo-change {
    font-size: 0.78rem;
    font-weight: 700;
    margin-top: 4px;
  }
  .stats-guest-banner {
    background: #fef9ee;
    border: 1px solid #e8d9a0;
    border-radius: 8px;
    padding: 10px 14px;
    margin-bottom: 14px;
    font-size: 0.8rem;
    color: #5a4a1a;
    text-align: center;
    line-height: 1.5;
  }
  .stats-guest-banner button {
    margin-top: 8px;
    background: #2c2c2c;
    color: #f5f0e8;
    border: none;
    border-radius: 6px;
    padding: 6px 16px;
    font-size: 0.8rem;
    cursor: pointer;
    font-family: 'Noto Serif', serif;
  }

  /* Confirm modal */
  .confirm-msg { font-size: 0.85rem; color: #8b7355; margin: 0 0 20px; line-height: 1.5; text-align: center; }
  .confirm-actions { display: flex; gap: 10px; justify-content: center; }
  .btn-confirm-cancel {
    padding: 9px 20px; border: 1.5px solid #c8bda8; border-radius: 4px;
    background: transparent; color: #555;
    font-family: 'Noto Serif', serif; font-size: 0.85rem; cursor: pointer;
  }
  .btn-confirm-cancel:hover { border-color: #2c2c2c; color: #2c2c2c; }
  .btn-confirm-ok {
    padding: 9px 20px; border: none; border-radius: 4px;
    color: #f5f0e8; font-family: 'Noto Serif', serif; font-size: 0.85rem; cursor: pointer;
  }

  /* Settings */
  .setting-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e0d8cc;
  }
  .setting-row:last-child { border-bottom: none; }
  .setting-label { font-size: 0.9rem; }
  .toggle {
    position: relative;
    width: 46px;
    height: 26px;
    cursor: pointer;
  }
  .toggle input { opacity: 0; width: 0; height: 0; position: absolute; }
  .toggle-track {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 13px;
    transition: background 0.25s;
  }
  .toggle input:checked + .toggle-track { background: #8b6914; }
  .toggle-thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.25s;
    box-shadow: 0 1px 3px #00000022;
  }
  .toggle input:checked ~ .toggle-thumb { transform: translateX(20px); }

  .settings-close-wrap { text-align: center; margin-top: 16px; }
  .btn-settings-close {
    padding: 7px 24px;
    border: none;
    border-radius: 4px;
    background: #2c2c2c;
    color: #f5f0e8;
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    cursor: pointer;
  }

  /* ============ ENDGAME ============ */
  .endgame-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.3);
    z-index: 90;
    align-items: center;
    justify-content: center;
    padding: 20px;
  }
  .endgame-overlay.open { display: flex; }
  .endgame {
    background: #f5f0e8;
    border-radius: 8px;
    padding: 28px 32px;
    width: min(280px, 82vw);
    text-align: center;
    animation: popIn 0.3s ease-out;
    color: #2c2c2c;
    box-shadow: 0 8px 40px #00000022;
    border: 1px solid #d4c9b8;
  }
  @keyframes popIn {
    0% { transform: scale(0.8); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
  }
  .endgame-icon { font-size: 2.5rem; margin-bottom: 8px; }
  .endgame-result {
    font-family: 'Noto Serif SC', serif;
    font-size: 1.3rem;
    font-weight: 700;
    margin-bottom: 4px;
  }
  .endgame-result.win { color: #2c2c2c; }
  .endgame-result.lose { color: #c23b22; }
  .endgame-result.draw { color: #8b6914; }
  .endgame-sub { font-size: 0.8rem; color: #8b7355; margin-bottom: 22px; }
  .endgame-actions { display: flex; gap: 10px; justify-content: center; }
  .btn-play-now {
    padding: 9px 24px;
    border: none;
    border-radius: 4px;
    background: #2c2c2c;
    color: #f5f0e8;
    font-family: 'Noto Serif', serif;
    font-size: 0.85rem;
    cursor: pointer;
  }
  .btn-change-diff {
    padding: 9px 14px;
    border: 1.5px solid #c8bda8;
    border-radius: 4px;
    background: transparent;
    color: #8b7355;
    font-family: 'Noto Serif', serif;
    font-size: 0.8rem;
    cursor: pointer;
  }
  .btn-change-diff:hover { border-color: #2c2c2c; color: #2c2c2c; }

  /* ===== BOT PRE-GAME OVERLAY ===== */
  #botPregameOverlay { z-index: 200; }
  .bot-pregame-inner {
    position: relative; display: flex; flex-direction: column; align-items: center;
    padding: 60px 28px 24px; width: min(300px, 86vw);
  }
  .bot-pregame-back {
    position: absolute; top: 14px; left: 14px;
    font-family: 'Noto Serif', serif; font-size: 0.75rem; color: #8b7355;
    border: 1px solid #d4ccc0; background: none; padding: 4px 10px;
    border-radius: 2px; cursor: pointer;
  }
  .bot-pregame-back:hover { border-color: #2c2c2c; color: #2c2c2c; }
  .bot-pregame-avatar-wrap { position: relative; margin-bottom: 12px; }
  .bot-pregame-avatar {
    width: 72px; height: 72px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df; display: block;
  }
  .bot-pregame-flag { position: absolute; bottom: 0; right: -4px; font-size: 20px; line-height: 1; }
  .bot-pregame-name {
    font-family: 'Noto Serif SC', serif; font-size: 1.15rem; font-weight: 700;
    color: #2c2c2c; margin-bottom: 3px;
  }
  .bot-pregame-meta { font-size: 0.72rem; color: #8b7355; margin-bottom: 10px; }
  .bot-pregame-style {
    font-size: 0.58rem; letter-spacing: 1.5px; text-transform: uppercase;
    padding: 3px 10px; border-radius: 2px; margin-bottom: 16px;
  }
  .bot-pregame-divider { width: 100%; border: none; border-top: 0.5px solid #d4ccc0; margin-bottom: 16px; }
  .bot-pregame-colors { display: flex; gap: 10px; width: 100%; margin-bottom: 20px; }
  .bot-color-card {
    flex: 1; border: 0.5px solid #d4ccc0; border-radius: 6px;
    padding: 10px 6px; text-align: center; background: rgba(255,255,255,0.55);
  }
  .bot-color-card.you { border-color: #2c2c2c; border-width: 1.5px; background: rgba(255,255,255,0.85); }
  .bot-color-stone { font-size: 22px; display: block; margin-bottom: 4px; }
  .bot-color-who { font-size: 0.58rem; color: #8b7355; margin-bottom: 1px; }
  .bot-color-name { font-size: 0.68rem; font-weight: 700; color: #2c2c2c; }
  .bot-color-first { font-size: 0.56rem; color: #c8a96e; margin-top: 2px; min-height: 0.8em; }
  .bot-pregame-start {
    width: 100%; background: #2c2c2c; color: #f5f0e8; border: none;
    padding: 13px; font-family: 'Noto Serif SC', serif; font-size: 0.85rem;
    font-weight: 700; letter-spacing: 2px; border-radius: 3px; cursor: pointer;
  }
  .bot-pregame-start:hover { background: #444; }

  /* Pregame matchup layout */
  .pregame-matchup {
    display: flex; align-items: center; gap: 12px; width: 100%;
    margin-bottom: 14px;
  }
  .pregame-side {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px;
  }
  .pregame-avatar-wrap {
    position: relative; width: 56px; height: 56px; flex-shrink: 0;
  }
  .pregame-side-avatar {
    width: 56px; height: 56px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df;
    display: block; cursor: pointer;
  }
  .player-side .pregame-side-avatar { border-color: #c8a96e; }
  .bot-pregame-flag {
    position: absolute; bottom: -4px; right: -4px;
    font-size: 1rem; line-height: 1; pointer-events: none;
  }
  .pregame-side-name {
    font-family: 'Noto Serif SC', serif; font-size: 0.82rem; font-weight: 700;
    color: #2c2c2c; text-align: center; max-width: 90px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .pregame-side-elo { font-size: 0.65rem; color: #8b7355; }
  .pregame-vs-label {
    font-family: 'Noto Serif SC', serif; font-size: 0.9rem; font-weight: 700;
    color: #c8a96e; letter-spacing: 2px; flex-shrink: 0;
  }
  /* Profile setup modal */
  .profile-setup-modal { max-width: 300px; }
  .profile-setup-sub { font-size: 0.8rem; color: #8b7355; margin: -8px 0 18px; text-align: center; }
  .profile-avatar-section {
    display: flex; flex-direction: column; align-items: center; gap: 8px;
    margin-bottom: 16px;
  }
  .profile-avatar-preview {
    width: 72px; height: 72px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df;
  }
  .profile-shuffle-btn {
    background: none; border: 1px solid #d4ccc0; padding: 4px 12px;
    font-family: 'Noto Serif', serif; font-size: 0.75rem; color: #8b7355;
    border-radius: 2px; cursor: pointer;
  }
  .profile-shuffle-btn:hover { border-color: #2c2c2c; color: #2c2c2c; }
  .profile-name-input {
    width: 100%; box-sizing: border-box; padding: 9px 12px; margin-bottom: 14px;
    border: 1px solid #d4ccc0; border-radius: 3px; font-family: 'Noto Serif', serif;
    font-size: 0.9rem; background: #fff; color: #2c2c2c; outline: none;
  }
  .profile-name-input:focus { border-color: #2c2c2c; }
  .profile-setup-actions { display: flex; gap: 8px; }
  /* Settings danger zone */
  .settings-danger { margin-top: 16px; padding-top: 14px; border-top: 0.5px solid #e0d8cc; }
  .btn-danger-small {
    background: none; border: 1px solid #e0ccc0; padding: 5px 12px;
    font-family: 'Noto Serif', serif; font-size: 0.75rem; color: #c0392b;
    border-radius: 2px; cursor: pointer;
  }
  .btn-danger-small:hover { border-color: #c0392b; background: #fdf0ee; }
  .settings-profile-row {
    display: flex; align-items: center; gap: 10px; margin-top: 14px;
    padding-top: 12px; border-top: 0.5px solid #e0d8cc;
  }
  .settings-profile-thumb {
    width: 32px; height: 32px; border-radius: 50%; border: 1.5px solid #d4ccc0;
    background: #ede8df; flex-shrink: 0;
  }
  .settings-profile-text {
    flex: 1; font-size: 0.8rem; color: #2c2c2c; font-family: 'Noto Serif SC', serif;
    font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .settings-profile-btns { display: flex; gap: 5px; flex-shrink: 0; }
  .settings-profile-action {
    background: none; border: 1px solid #d4ccc0; padding: 3px 9px;
    font-family: 'Noto Serif', serif; font-size: 0.7rem; color: #8b7355;
    border-radius: 2px; cursor: pointer;
  }
  .settings-profile-action:hover { border-color: #2c2c2c; color: #2c2c2c; }
  .settings-profile-action.danger { color: #c0392b; border-color: #e0ccc0; }
  .settings-profile-action.danger:hover { border-color: #c0392b; background: #fdf0ee; }

  /* ===== BOT GAME HEADER ===== */
  #botGameHeader {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 14px; border-bottom: 0.5px solid #e0d8cc;
    background: rgba(245,240,232,0.95); gap: 6px;
  }
  #botGameHeader.hidden { display: none !important; }
  .bgh-player, .bgh-bot { display: flex; align-items: center; gap: 7px; flex: 1; min-width: 0; }
  .bgh-bot { flex-direction: row-reverse; }
  .bgh-player-avatar, .bgh-avatar {
    width: 30px; height: 30px; border-radius: 50%;
    border: 1.5px solid #d4ccc0; background: #ede8df; flex-shrink: 0;
  }
  .bgh-name-row {
    display: flex; align-items: center; gap: 3px; justify-content: flex-end; min-width: 0;
  }
  .bgh-flag { font-size: 0.78rem; line-height: 1; flex-shrink: 0; }
  .bgh-name { flex-shrink: 1; white-space: nowrap; overflow: hidden; text-overflow: clip; }
  .bgh-player-name, .bgh-name {
    font-family: 'Noto Serif SC', serif; font-size: 0.72rem; font-weight: 700;
    color: #2c2c2c; min-width: 0; overflow: hidden;
  }
  .bgh-player-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; min-width: 0; }
  .bgh-bot .bgh-name { text-align: right; }
  .bgh-bot-info { display: flex; flex-direction: column; align-items: flex-end; }
  .bgh-style-badge {
    display: inline-block; font-size: 0.5rem; letter-spacing: 1px;
    text-transform: uppercase; padding: 1px 5px; border-radius: 2px;
  }
  .bgh-style-badge.Aggressive { background: #fdebd0; color: #784212; }
  .bgh-style-badge.Balanced   { background: #eaf2ff; color: #1a5276; }
  .bgh-style-badge.Defensive  { background: #e8f8f5; color: #0e6655; }
  .bgh-player-elo, .bgh-bot-elo {
    font-size: 0.58rem; color: #8b7355; margin-top: 1px;
    font-family: 'Noto Serif', serif; white-space: nowrap;
  }
  .bgh-info-col { min-width: 0; overflow: hidden; display: flex; flex-direction: column; justify-content: center; flex: 1; }
  .bgh-vs-label {
    font-family: 'Noto Serif SC', serif; font-size: 0.65rem; color: #c8a96e;
    font-weight: 700; letter-spacing: 1px; flex-shrink: 0; padding: 0 4px;
  }
  #onlineGameHeader {
    display: flex; align-items: center; justify-content: space-between;
    padding: 7px 14px; border-bottom: 0.5px solid #e0d8cc;
    background: rgba(245,240,232,0.95); gap: 6px;
  }
  #onlineGameHeader.hidden { display: none !important; }
  #onlineGameHeader .bgh-player-name {
    white-space: normal; overflow: visible; text-overflow: clip;
    word-break: break-word; line-height: 1.2;
  }
  .ogh-avatar {
    width: 32px; height: 32px; border-radius: 50%; flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 13px; font-weight: 700;
    border: 1.5px solid transparent;
  }
  .ogh-avatar.turn-pulse { box-shadow: 0 0 0 2.5px #c8a96e; }
  #profileSetupOverlay { z-index: 300; }
  #endgameOverlay { z-index: 200; }
  #onlinePreGameOverlay { z-index: 216; }
  #egPrimaryBtn:disabled { background: #d4ccc0 !important; color: #8b7355 !important; cursor: not-allowed; animation: none; box-shadow: none; }
  #egPrimaryBtn.waiting { background: #d4c9b8 !important; color: #8b7355 !important; cursor: default; }
  #egPrimaryBtn.opponent-ready { background: #4a7c59 !important; color: #fff !important; animation: pulse-green 1s ease-in-out infinite; }
  @keyframes pulse-green { 0%,100% { box-shadow: 0 0 0 0 rgba(74,124,89,0.4); } 50% { box-shadow: 0 0 0 6px rgba(74,124,89,0); } }
  /* Pre-game screen */
  .opg-label {
    font-size: 0.6rem; letter-spacing: 2px; text-transform: uppercase;
    color: #8b7355; margin-bottom: 14px; font-family: 'Noto Serif', serif;
  }
  .opg-color-cards { display: flex; gap: 10px; width: 100%; margin-bottom: 18px; }
  .opg-color-card {
    flex: 1; border-radius: 10px; padding: 14px 8px; text-align: center;
    border: 2px solid transparent; cursor: default;
  }
  .opg-black { background: #2c2c2c; border-color: #2c2c2c; }
  .opg-white { background: #f5f0e8; border-color: #d4ccc0; }
  .opg-stone { font-size: 1.6rem; margin-bottom: 4px; }
  .opg-color-who { font-size: 0.65rem; color: #c8a96e; font-weight: 700; margin-bottom: 1px; font-family: 'Noto Serif', serif; }
  .opg-black .opg-color-who { color: #c8a96e; }
  .opg-white .opg-color-who { color: #8b7355; }
  .opg-color-name { font-size: 0.8rem; font-weight: 700; font-family: 'Noto Serif SC', serif; }
  .opg-black .opg-color-name { color: #f5f0e8; }
  .opg-white .opg-color-name { color: #2c2c2c; }
  .opg-color-sub { font-size: 0.6rem; margin-top: 2px; }
  .opg-black .opg-color-sub { color: #c8a96e; }
  .opg-white .opg-color-sub { color: #aaa; }

  /* Board header — style tooltip */
  .bgh-avatar-wrap { position: relative; display: inline-block; cursor: pointer; }

  .bgh-style-tooltip {
    position: absolute; bottom: 36px; right: 0;
    font-size: 0.55rem; letter-spacing: 1.5px; text-transform: uppercase;
    background: #2c2c2c; color: #f5f0e8; padding: 3px 7px;
    border-radius: 2px; white-space: nowrap; display: none; pointer-events: none;
    font-family: 'Noto Serif', serif;
  }
  .bgh-avatar-wrap:hover .bgh-style-tooltip { display: block; }
  .bgh-player-avatar { cursor: pointer; }

  /* Profile avatar grid */
  .profile-avatar-selected-wrap { margin: 8px 0 6px; text-align: center; }
  .profile-avatar-grid {
    display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px;
    width: 100%; margin-bottom: 12px; max-height: 190px; overflow-y: auto; padding-right: 3px;
  }
  .profile-avatar-grid-item {
    width: 100%; aspect-ratio: 1; border-radius: 50%;
    border: 2px solid transparent; cursor: pointer;
    background: #ede8df; overflow: hidden;
    transition: border-color 0.12s; display: block;
  }
  .profile-avatar-grid-item:hover { border-color: #c8a96e; }
  .profile-avatar-grid-item.selected { border-color: #2c2c2c; }
  .profile-avatar-grid-item img { width: 100%; height: 100%; display: block; }

  /* Stats profile card */
  .stats-profile-card {
    display: flex; align-items: center; gap: 12px;
    padding: 10px 0 14px; margin-bottom: 14px;
    border-bottom: 0.5px solid #e0d8cc;
  }
  .stats-profile-avatar {
    width: 48px; height: 48px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df; flex-shrink: 0; cursor: pointer;
  }
  .stats-profile-info { flex: 1; }
  .stats-profile-name {
    font-family: 'Noto Serif SC', serif; font-size: 0.9rem; font-weight: 700; color: #2c2c2c;
  }
  .stats-profile-tier { font-size: 0.65rem; color: #8b7355; margin-top: 1px; }
  .stats-edit-btn {
    background: none; border: 1px solid #d4ccc0; padding: 4px 10px;
    font-family: 'Noto Serif', serif; font-size: 0.72rem; color: #8b7355;
    border-radius: 2px; cursor: pointer; white-space: nowrap; flex-shrink: 0;
  }
  .stats-edit-btn:hover { border-color: #2c2c2c; color: #2c2c2c; }

  /* ===== BOT ENDGAME OVERLAY ===== */
  .bot-end-close {
    position: absolute; top: 10px; right: 12px;
    background: none; border: none; font-size: 1.3rem; color: #b0a090;
    cursor: pointer; line-height: 1; padding: 2px 6px;
  }
  .bot-end-close:hover { color: #2c2c2c; }
  .bot-end-matchup {
    display: flex; align-items: flex-start; gap: 12px; margin-bottom: 12px; width: 100%;
  }
  .bot-end-side {
    flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; min-width: 0;
  }
  .bot-end-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df; flex-shrink: 0;
  }
  .bot-end-avatar-player { border-color: #c8a96e; }
  .bot-end-side-name {
    font-family: 'Noto Serif SC', serif; font-size: 0.72rem; font-weight: 700;
    color: #2c2c2c; text-align: center; max-width: 80px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  }
  .bot-end-side-elo { font-size: 0.58rem; color: #8b7355; text-align: center; font-family: 'Noto Serif', serif; }
  .bot-end-side-tier { font-size: 0.55rem; color: #aaa; text-align: center; margin-top: 1px; font-family: 'Noto Serif', serif; }
  .bot-end-matchup-vs {
    font-family: 'Noto Serif SC', serif; font-size: 0.6rem; font-weight: 700;
    color: #c8a96e; letter-spacing: 1px; padding-top: 12px; flex-shrink: 0;
  }
  .bot-end-inner {
    display: flex; flex-direction: column; align-items: center;
    padding: 28px 28px 24px; width: min(300px, 86vw);
  }
  @keyframes popInBig {
    0% { transform: scale(0.5); opacity: 0; }
    60% { transform: scale(1.1); }
    100% { transform: scale(1); opacity: 1; }
  }
  @keyframes slideUp {
    0% { transform: translateY(16px); opacity: 0; }
    100% { transform: translateY(0); opacity: 1; }
  }
  .bot-end-icon { font-size: 3.2rem; margin-bottom: 6px; animation: popInBig 0.5s ease-out; }
  .bot-end-result {
    font-family: 'Noto Serif SC', serif; font-size: 1.6rem; font-weight: 700;
    margin-bottom: 3px; animation: slideUp 0.35s 0.15s both ease-out;
  }
  .bot-end-result.win { color: #2a7a3f; }
  .bot-end-result.lose { color: #c23b22; }
  .bot-end-result.draw { color: #8b6914; }
  .bot-end-vs {
    font-size: 0.72rem; color: #8b7355; margin-bottom: 18px;
    animation: slideUp 0.35s 0.25s both ease-out;
  }
  .bot-elo-box {
    background: rgba(255,255,255,0.7); border: 0.5px solid #d4ccc0; border-radius: 6px;
    padding: 12px 20px; margin-bottom: 18px; text-align: center; width: 100%;
    animation: slideUp 0.35s 0.35s both ease-out;
  }
  .bot-elo-box-label {
    font-size: 0.6rem; color: #8b7355; letter-spacing: 1.5px;
    text-transform: uppercase; margin-bottom: 8px;
  }
  .bot-elo-row { display: flex; align-items: center; justify-content: center; gap: 10px; }
  .bot-elo-old { font-size: 1.2rem; color: #bbb; font-weight: 700; }
  .bot-elo-arr { font-size: 0.85rem; color: #bbb; }
  .bot-elo-new { font-size: 1.9rem; font-weight: 700; color: #2c2c2c; transition: transform 0.15s ease-out; }
  @keyframes eloSettle {
    0%   { transform: scale(1.35); }
    60%  { transform: scale(0.95); }
    100% { transform: scale(1); }
  }
  .bot-elo-new.settled { animation: eloSettle 0.4s ease-out forwards; }
  .bot-elo-delta { font-size: 0.78rem; font-weight: 700; padding: 2px 8px; border-radius: 3px; }
  .bot-elo-delta.pos { background: #eaf3de; color: #3b6d11; }
  .bot-elo-delta.neg { background: #fcebeb; color: #a32d2d; }
  .bot-elo-delta.zero { background: #f0ece4; color: #8b7355; }
  .bot-end-actions {
    display: flex; flex-direction: column; gap: 8px; width: 100%;
    animation: slideUp 0.35s 0.45s both ease-out;
  }
  .bot-btn-primary {
    width: 100%; background: #2c2c2c; color: #f5f0e8; border: none;
    padding: 13px; font-family: 'Noto Serif SC', serif; font-size: 0.85rem;
    font-weight: 700; letter-spacing: 1px; border-radius: 3px; cursor: pointer;
  }
  .bot-btn-primary:hover { background: #444; }
  .bot-btn-secondary {
    width: 100%; background: none; border: 0.5px solid #d4ccc0; color: #2c2c2c;
    padding: 11px; font-family: 'Noto Serif', serif; font-size: 0.82rem;
    border-radius: 3px; cursor: pointer;
  }
  .bot-btn-secondary:hover { border-color: #2c2c2c; }
  .bot-btn-ghost {
    width: 100%; background: none; border: none; color: #8b7355;
    padding: 8px; font-family: 'Noto Serif', serif; font-size: 0.78rem; cursor: pointer;
  }
  .bot-btn-ghost:hover { color: #2c2c2c; }
  .bot-btn-link {
    background: none; border: none; color: #aaa; padding: 4px 8px;
    font-family: 'Noto Serif', serif; font-size: 0.75rem; cursor: pointer;
    text-decoration: underline; text-underline-offset: 2px;
  }
  .bot-btn-link:hover { color: #2c2c2c; }
  .bot-end-action-row {
    display: flex; gap: 8px; width: 100%;
  }
  .bot-end-action-row .bot-btn-secondary { width: 50%; }

  /* ====== DAILY PUZZLE MODE ====== */
  body.daily-mode .actions { display: none !important; }

  /* Daily puzzle label + progress row + next button */
  .daily-puzzle-label {
    font-size: 0.76rem;
    color: #8b7355;
    letter-spacing: 0.5px;
    margin-top: -2px;
  }
  .daily-progress-row {
    display: flex;
    gap: 5px;
    margin-top: 3px;
  }
  .progress-sq {
    width: 13px;
    height: 13px;
    border-radius: 2px;
    background: #e0d8cc;
    border: 1.5px solid #c8bda8;
    transition: background 0.3s, border-color 0.3s;
  }
  .progress-sq.active  { background: #8b6914; border-color: #8b6914; }
  .progress-sq.solved  { background: #4a7c59; border-color: #4a7c59; }
  .progress-sq.close   { background: #c8a96e; border-color: #c8a96e; }
  .progress-sq.failed  { background: #c23b22; border-color: #c23b22; }

  .daily-next-btn {
    margin-top: 6px;
    padding: 7px 20px;
    background: #2c2c2c;
    color: #f5f0e8;
    border: none;
    border-radius: 4px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.82rem;
    cursor: pointer;
    letter-spacing: 0.5px;
    transition: background 0.2s;
  }
  .daily-next-btn:hover { background: #444; }
  .daily-next-btn.hidden { display: none !important; }

  /* Daily panel (puzzle # / streak / turn / attempt dots) */
  #dailyPanel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
    padding: 8px 0 2px;
  }
  #dailyPanel.hidden { display: none !important; }

  .daily-info-row {
    display: flex;
    align-items: center;
    gap: 14px;
  }
  .daily-num {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.88rem;
    color: #8b6914;
    letter-spacing: 1px;
    text-transform: uppercase;
  }
  .daily-streak-badge {
    font-size: 0.85rem;
    color: #c8a96e;
    min-width: 28px;
  }
  .daily-turn-label {
    font-size: 0.82rem;
    color: #5c4a2a;
    letter-spacing: 0.5px;
  }
  .daily-attempt-label {
    font-size: 0.72rem;
    color: #8b7355;
    letter-spacing: 0.5px;
  }
  .daily-attempt-label.hidden { display: none !important; }

  /* Daily result panel */
  #dailyResultPanel {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 14px 20px 18px;
    background: #f5f0e8;
    border-top: 1px solid #e0d8cc;
    text-align: center;
  }
  #dailyResultPanel.hidden { display: none !important; }
  .daily-result-icon { font-size: 1.8rem; line-height: 1; }
  .daily-result-title {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    color: #2c2c2c;
    margin: 0;
  }
  .daily-result-sub {
    font-size: 0.82rem;
    color: #8b7355;
    max-width: 280px;
    line-height: 1.5;
    margin: 0;
  }
  .daily-share-text {
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.82rem;
    background: #fff;
    border: 1px solid #e0d8cc;
    border-radius: 4px;
    padding: 8px 14px;
    white-space: pre;
    color: #2c2c2c;
    letter-spacing: 0.3px;
    line-height: 1.6;
  }
  .daily-share-btn {
    padding: 8px 22px;
    background: #2c2c2c;
    color: #f5f0e8;
    border: none;
    border-radius: 4px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.83rem;
    cursor: pointer;
    transition: background 0.2s;
    letter-spacing: 0.5px;
  }
  .daily-share-btn:hover { background: #444; }
  .daily-share-btn.copied { background: #4a7c59; }
  .daily-next-label {
    font-size: 0.75rem;
    color: #bbb;
    letter-spacing: 0.5px;
  }

  /* Stone states for daily guesses */
  .stone.daily-wrong   { opacity: 0.55; }
  .stone.daily-correct { box-shadow: 0 0 0 3px #c8a96e, 0 0 14px #c8a96e99; }
  .stone.daily-reveal  {
    opacity: 0.75;
    box-shadow: 0 0 0 3px #c8a96e;
    animation: revealPulse 1.2s ease-out forwards;
  }
  @keyframes revealPulse {
    0%   { box-shadow: 0 0 0 3px #c8a96e, 0 0 20px #c8a96ecc; }
    100% { box-shadow: 0 0 0 3px #c8a96e; }
  }

  /* Rank number overlay on guess stones */
  .guess-rank-label {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: 0.58rem;
    font-weight: 700;
    color: rgba(255,255,255,0.92);
    pointer-events: none;
    line-height: 1;
    z-index: 2;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
  }

  /* Review navigation bar inside daily panel */
  .daily-review-nav {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 2px;
  }
  .daily-review-nav.hidden { display: none !important; }
  .review-nav-btn {
    padding: 4px 10px;
    background: #2c2c2c;
    color: #f5f0e8;
    border: none;
    border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.75rem;
    cursor: pointer;
    transition: background 0.2s;
  }
  .review-nav-btn:hover:not(:disabled) { background: #444; }
  .review-nav-btn:disabled { opacity: 0.35; cursor: default; }
  .review-nav-label {
    font-size: 0.78rem;
    color: #8b7355;
    min-width: 80px;
    text-align: center;
  }
  .review-done-btn {
    padding: 4px 12px;
    background: #c8a96e;
    color: #2c2c2c;
    border: none;
    border-radius: 3px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.75rem;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.2s;
  }
  .review-done-btn:hover { background: #b8914e; }
  /* Review Puzzles button in result panel */
  .daily-review-btn {
    padding: 7px 18px;
    background: transparent;
    color: #8b7355;
    border: 1px solid #c8bda8;
    border-radius: 4px;
    font-family: 'Noto Serif', Georgia, serif;
    font-size: 0.8rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
  }
  .daily-review-btn:hover { background: #e0d8cc; color: #2c2c2c; }

  /* ===== BOT SELECT SCREEN ===== */
  /* ===== BOT SELECT SCREEN ===== */
  #botSelectScreen {
    position: fixed; inset: 0; z-index: 210; background: #f5f0e8;
    display: flex; flex-direction: column; overflow-y: auto;
  }
  #botSelectScreen.hidden { display: none; }
  .bot-select-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 12px 14px; border-bottom: 1px solid #e0d8cc;
    background: #f5f0e8; position: sticky; top: 0; z-index: 2; gap: 8px;
  }
  .bot-select-nav-group { display: flex; gap: 6px; }
  .bot-select-title-section {
    text-align: center; padding: 20px 16px 6px;
  }
  .bot-select-title-heading {
    font-family: 'Noto Serif SC', serif; font-size: 1.05rem; font-weight: 700;
    color: #2c2c2c; letter-spacing: 1px; margin-bottom: 10px;
  }
  .bot-select-elo-pill {
    display: inline-block;
    font-family: 'Noto Serif SC', serif; font-size: 0.72rem; font-weight: 700;
    background: #2c2c2c; color: #f5f0e8; padding: 3px 10px; border-radius: 20px;
    white-space: nowrap;
  }
  .bot-select-back {
    background: none; border: 1px solid #d4ccc0; padding: 5px 12px;
    font-family: 'Noto Serif', serif; font-size: 0.78rem; cursor: pointer;
    color: #2c2c2c; border-radius: 2px; white-space: nowrap;
  }
  .bot-select-back:hover { border-color: #2c2c2c; }

  .bot-select-elo-pill {
    font-family: 'Noto Serif SC', serif; font-size: 0.72rem; font-weight: 700;
    background: #2c2c2c; color: #f5f0e8; padding: 3px 10px; border-radius: 20px;
    white-space: nowrap;
  }


  /* Tier sections */
  #botSelectBody { display: flex; flex-direction: column; align-items: center; }
  .bot-tier-section { padding: 12px 12px 0; width: 100%; max-width: 320px; }
  .bot-tier-label {
    font-family: 'Noto Serif SC', serif; font-size: 0.82rem; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase; color: #2c2c2c;
    margin-bottom: 8px; padding-bottom: 4px; border-bottom: 1.5px solid #d4ccc0;
  }
  .bot-elo-group { margin-bottom: 10px; }
  .bot-elo-row-grid {
    display: grid; grid-template-columns: repeat(3, 82px); gap: 6px;
  }

  /* Compact card */
  .bot-card {
    display: flex; flex-direction: column; align-items: center;
    padding: 8px 4px 6px; background: rgba(255,255,255,0.75);
    border: 1.5px solid #d4ccc0; border-radius: 4px; cursor: pointer;
    transition: border-color 0.15s, background 0.15s; position: relative;
    text-align: center; overflow: visible;
  }
  .bot-card:hover:not(.bot-locked) { border-color: #2c2c2c; background: #fff; }
  .bot-card.bot-locked { cursor: default; border-color: #e8e2d8; }
  .bot-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    border: 1.5px solid #e0d8cc; margin-bottom: 4px; background: #ede8df;
    display: block;
  }
  .bot-card.bot-locked .bot-avatar { filter: grayscale(1); opacity: 0.45; }
  .bot-card.bot-locked .bot-name { opacity: 0.45; }
  .bot-name {
    font-family: 'Noto Serif SC', serif; font-size: 0.68rem;
    font-weight: 700; color: #2c2c2c; line-height: 1.2;
  }
  .bot-flag { font-size: 0.72rem; }
  .bot-beaten-pip {
    position: absolute; top: 3px; right: 4px;
    width: 6px; height: 6px; border-radius: 50%;
    background: #c8a96e;
  }
  .bot-lock-pip {
    position: absolute; top: 3px; right: 4px;
    font-size: 0.55rem; color: #ccc; line-height: 1;
  }

  /* Tooltip (desktop hover) */
  .bot-tooltip {
    display: none; position: absolute;
    bottom: calc(100% + 7px); left: 50%; transform: translateX(-50%);
    background: #2c2c2c; color: #f5f0e8;
    padding: 7px 10px; border-radius: 4px;
    font-size: 0.68rem; line-height: 1.5;
    white-space: nowrap; z-index: 20; pointer-events: none;
    text-align: center;
  }
  .bot-tooltip::after {
    content: ''; position: absolute; top: 100%; left: 50%; transform: translateX(-50%);
    border: 5px solid transparent; border-top-color: #2c2c2c;
  }
  .bot-card:not(.bot-locked):hover .bot-tooltip { display: block; }
  .bot-card.bot-locked:hover .bot-locked-tooltip { display: block; }
  .bot-tooltip-style { font-size: 0.6rem; opacity: 0.7; margin-top: 1px; }

  /* Bot challenge panel (mobile tap / all click) */
  #botPanel {
    position: fixed; bottom: 0; left: 0; right: 0; z-index: 300;
    background: #f5f0e8; border-top: 1.5px solid #d4ccc0;
    padding: 20px 20px 28px;
    display: flex; flex-direction: column; align-items: center; gap: 10px;
    transform: translateY(100%); transition: transform 0.25s ease;
  }
  #botPanel.open { transform: translateY(0); }
  .bot-panel-avatar {
    width: 64px; height: 64px; border-radius: 50%;
    border: 2px solid #d4ccc0; background: #ede8df;
  }
  .bot-panel-name {
    font-family: 'Noto Serif SC', serif; font-size: 1.1rem; font-weight: 700;
  }
  .bot-panel-meta { font-size: 0.75rem; color: #8b7355; }
  .bot-panel-record { font-size: 0.72rem; color: #999; }
  .bot-panel-style-badge {
    font-size: 0.62rem; letter-spacing: 1px; text-transform: uppercase;
    padding: 2px 8px; border-radius: 2px;
  }
  .bot-panel-style-badge.Aggressive { background: #fdebd0; color: #784212; }
  .bot-panel-style-badge.Balanced   { background: #eaf2ff; color: #1a5276; }
  .bot-panel-style-badge.Defensive  { background: #e8f8f5; color: #0e6655; }
  .bot-panel-actions { display: flex; gap: 10px; margin-top: 4px; width: 100%; max-width: 280px; }
  .bot-panel-challenge {
    flex: 1; background: #2c2c2c; color: #f5f0e8; border: none;
    padding: 12px; font-family: 'Noto Serif SC', serif; font-size: 0.85rem;
    font-weight: 700; letter-spacing: 2px; cursor: pointer; border-radius: 2px;
  }
  .bot-panel-challenge:hover { background: #444; }
  .bot-panel-cancel {
    background: none; border: 1px solid #d4ccc0; padding: 12px 16px;
    font-family: 'Noto Serif', serif; font-size: 0.8rem; cursor: pointer;
    color: #999; border-radius: 2px;
  }
  .bot-panel-cancel:hover { border-color: #999; color: #2c2c2c; }

  /* Bot stats modal */
  #botStatsOverlay {
    display: none; position: fixed; inset: 0; z-index: 400;
    background: rgba(0,0,0,0.45); align-items: center; justify-content: center;
  }
  #botStatsOverlay.open { display: flex; }
  .bot-stats-modal {
    background: #f5f0e8; padding: 24px 20px; max-width: 380px; width: 90%;
    max-height: 85vh; overflow-y: auto; border-radius: 2px;
    font-family: 'Noto Serif', Georgia, serif;
  }
  .bot-stats-modal h3 {
    font-family: 'Noto Serif SC', serif; font-size: 0.9rem; font-weight: 700;
    letter-spacing: 2px; text-transform: uppercase; color: #999;
    margin: 16px 0 8px; border-top: 1px solid #e0d8cc; padding-top: 12px;
  }
  .bot-stats-modal h3:first-child { border-top: none; padding-top: 0; margin-top: 0; }
  .bot-elo-display {
    text-align: center; margin-bottom: 4px;
  }
  .bot-elo-number {
    font-size: 2.6rem; font-weight: 900; color: #2c2c2c;
    font-family: 'Noto Serif SC', serif; line-height: 1;
  }
  .bot-elo-label { font-size: 0.68rem; color: #999; letter-spacing: 2px; text-transform: uppercase; }
  .elo-track {
    position: relative; height: 6px; background: #e0d8cc; border-radius: 3px;
    margin: 12px 0 4px;
  }
  .elo-track-fill {
    height: 100%; background: #2c2c2c; border-radius: 3px; transition: width 0.6s ease;
  }
  .elo-track-marker {
    position: absolute; top: -3px; width: 12px; height: 12px;
    background: #c8a96e; border-radius: 50%; transform: translateX(-50%);
    border: 2px solid #f5f0e8;
  }
  .elo-track-labels {
    display: flex; justify-content: space-between;
    font-size: 0.58rem; color: #bbb; margin-top: 2px;
  }
  .stats-filter-tabs { display: flex; gap: 6px; margin: 6px 0 10px; }
  .stats-filter-tab {
    flex: 1; padding: 5px 0; font-size: 0.68rem; font-family: 'Noto Serif', serif;
    border: 1.5px solid #d0c8b8; border-radius: 4px; background: transparent;
    color: #8b7355; cursor: pointer; transition: all 0.15s;
  }
  .stats-filter-tab.active { background: #2c2c2c; color: #f5f0e8; border-color: #2c2c2c; }
  .stats-filter-tab:hover:not(.active) { border-color: #8b7355; color: #2c2c2c; }
  .tier-bar-row {
    display: flex; align-items: center; gap: 8px; margin-bottom: 7px;
  }
  .tier-bar-label { font-size: 0.7rem; color: #8b7355; width: 90px; flex-shrink: 0; }
  .tier-bar-track {
    flex: 1; height: 8px; background: #e0d8cc; border-radius: 4px; overflow: hidden;
  }
  .tier-bar-fill { height: 100%; background: #2c2c2c; border-radius: 4px; }
  .tier-bar-pct { font-size: 0.68rem; color: #999; width: 30px; text-align: right; flex-shrink: 0; }
  .tier-bar-games { font-size: 0.62rem; color: #bbb; }
  .bot-stats-close-btn {
    display: block; width: 100%; margin-top: 20px;
    background: #2c2c2c; color: #f5f0e8; border: none;
    padding: 11px; font-family: 'Noto Serif SC', serif; font-size: 0.82rem;
    font-weight: 700; letter-spacing: 2px; cursor: pointer; border-radius: 2px;
  }
  .bot-stats-close-btn:hover { background: #444; }
  .bot-stats-reset-btn {
    margin-top: 20px; background: none; border: 1px solid #d4ccc0;
    padding: 11px 14px; font-family: 'Noto Serif', serif; font-size: 0.78rem;
    color: #c0392b; cursor: pointer; border-radius: 2px; white-space: nowrap;
  }
  .bot-stats-reset-btn:hover { border-color: #c0392b; background: #fdf0ee; }
  .bots-unlocked-row {
    display: flex; align-items: center; gap: 10px; margin: 6px 0;
  }
  .bots-unlocked-track {
    flex: 1; height: 6px; background: #e0d8cc; border-radius: 3px; overflow: hidden;
  }
  .bots-unlocked-fill { height: 100%; background: #c8a96e; border-radius: 3px; }
  .bots-unlocked-label { font-size: 0.72rem; color: #8b7355; white-space: nowrap; }
  /* Splash + bot-select settings buttons */
  .splash-settings-corner {
    position: absolute; top: 12px; right: 14px;
    display: flex; align-items: center; gap: 6px;
  }

  .splash-settings-btn {
    background: none; border: 1px solid #d4ccc0; padding: 0;
    width: 30px; height: 30px;
    color: #8b7355; border-radius: 2px; cursor: pointer; line-height: 1;
    display: inline-flex; align-items: center; justify-content: center;
  }
  .splash-settings-btn:hover { border-color: #2c2c2c; color: #2c2c2c; }

  /* ====== GAME REVIEW ====== */
  #reviewOverlay {
    display: none; position: fixed; inset: 0; z-index: 220;
    background: rgba(44,44,44,0.65); align-items: center; justify-content: center;
  }
  #reviewOverlay.open { display: flex; }
  .review-modal {
    background: #f5f0e8; border-radius: 4px; padding: 28px 24px 22px;
    width: min(340px, 90vw); display: flex; flex-direction: column; align-items: center; gap: 0;
    position: relative;
  }
  .review-header-label {
    font-size: 0.62rem; letter-spacing: 2px; text-transform: uppercase;
    color: #999; margin-bottom: 6px;
  }
  .beta-tag {
    display: inline-block; font-size: 0.5rem; font-weight: 700; letter-spacing: 1px;
    background: #8b6914; color: #fff; padding: 1px 5px; border-radius: 2px;
    vertical-align: middle; text-transform: uppercase; margin-left: 4px;
    font-family: 'Noto Serif', serif;
  }
  .review-accuracy-num {
    font-size: 3.2rem; font-weight: 900; color: #2c2c2c; line-height: 1;
  }
  .review-accuracy-label {
    font-size: 0.78rem; color: #8b7355; margin-top: 4px; margin-bottom: 18px;
    font-family: 'Noto Serif', serif; letter-spacing: 1px;
  }
  .review-quality-row {
    display: flex; gap: 8px; margin-bottom: 18px; width: 100%;
  }
  .review-quality-pill {
    flex: 1; display: flex; flex-direction: column; align-items: center;
    padding: 7px 4px; border-radius: 4px; font-family: 'Noto Serif', serif;
  }
  .review-quality-pill .rqp-count { font-size: 1.1rem; font-weight: 700; }
  .review-quality-pill .rqp-label { font-size: 0.55rem; letter-spacing: 0.5px; margin-top: 2px; }
  .rqp-best    { background: #e8f5e9; color: #2e7d32; }
  .rqp-good    { background: #fff8e1; color: #f57f17; }
  .rqp-inaccuracy { background: #fff3e0; color: #e65100; }
  .rqp-mistake { background: #fce4ec; color: #b71c1c; }
  .review-move-total {
    font-size: 0.65rem; color: #aaa; margin-bottom: 18px;
  }
  .review-sparkline-wrap {
    width: 100%; margin-bottom: 18px; position: relative;
  }
  .review-sparkline-label {
    font-size: 0.6rem; color: #aaa; letter-spacing: 1px; text-transform: uppercase;
    margin-bottom: 5px;
  }
  .review-sparkline-tooltip {
    display: none; position: absolute; background: #2c2c2c; color: #f5f0e8;
    font-family: 'Noto Serif', serif; font-size: 0.68rem; line-height: 1.5;
    padding: 6px 9px; border-radius: 3px; white-space: nowrap; z-index: 10;
    pointer-events: none; bottom: calc(100% + 4px); left: 50%; transform: translateX(-50%);
  }
  .review-sparkline-tooltip.visible { display: block; }
  .review-actions { display: flex; flex-direction: column; gap: 8px; width: 100%; }
  .review-btn-primary {
    background: #2c2c2c; color: #f5f0e8; border: none; border-radius: 3px;
    font-family: 'Noto Serif', serif; font-size: 0.82rem; padding: 11px;
    cursor: pointer; letter-spacing: 0.5px; width: 100%;
  }
  .review-btn-ghost {
    background: transparent; color: #8b7355; border: 1.5px solid #c8bda8;
    border-radius: 3px; font-family: 'Noto Serif', serif; font-size: 0.82rem;
    padding: 9px; cursor: pointer; letter-spacing: 0.5px; width: 100%;
  }
  .review-btn-ghost:hover { color: #2c2c2c; border-color: #2c2c2c; }

  /* Review nav strip (move replay) */
  #reviewNavStrip {
    display: flex; align-items: center; justify-content: center; gap: 12px;
    padding: 10px 0 6px; width: 100%;
  }
  #reviewNavStrip.hidden { display: none !important; }
  #unrankedBadge.hidden { display: none !important; }
  .review-nav-btn {
    background: none; border: 1.5px solid #c8bda8; border-radius: 3px;
    color: #8b7355; font-size: 1rem; cursor: pointer; padding: 4px 14px;
    transition: all 0.15s;
  }
  .review-nav-btn:hover:not(:disabled) { border-color: #2c2c2c; color: #2c2c2c; }
  .review-nav-btn:disabled { opacity: 0.3; cursor: default; }
  #reviewStepLabel {
    font-family: 'Noto Serif', serif; font-size: 0.72rem; color: #8b7355;
    min-width: 100px; text-align: center;
  }
  .review-exit-btn {
    background: none; border: none; color: #aaa; font-size: 0.72rem;
    cursor: pointer; padding: 4px 8px; margin-left: 4px;
  }
  .review-exit-btn:hover { color: #2c2c2c; }

  /* Quality dot overlays on stones during replay */
  .cell.review-best::after,
  .cell.review-good::after,
  .cell.review-inaccuracy::after,
  .cell.review-mistake::after {
    content: ''; position: absolute; width: 8px; height: 8px;
    border-radius: 50%; top: 2px; right: 2px; z-index: 5;
    border: 1px solid rgba(255,255,255,0.6);
  }
.cell.review-best::after        { background: #43a047; }
  .cell.review-good::after        { background: #fb8c00; }
  .cell.review-inaccuracy::after  { background: #ef6c00; }
  .cell.review-mistake::after     { background: #e53935; }
  /* Last-placed stone pulse ring */
  .cell.review-last-move::before {
    content: ''; position: absolute; inset: 2px; border-radius: 50%;
    border: 2px solid rgba(255,215,0,0.85); z-index: 6;
    animation: reviewPulse 1.2s ease-in-out infinite;
  }
  @keyframes reviewPulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(1.12); }
  }
  /* Best-move suggestion highlight */
  .cell.review-best-move {
    background: rgba(33,150,243,0.25) !important;
    border-radius: 50%;
  }
  .cell.review-best-move::before {
    content: '★'; position: absolute; font-size: 0.6rem; color: #1565c0;
    top: 1px; left: 2px; z-index: 5;
  }

  /* Sparkline in stats modal */
  .stats-sparkline-section { width: 100%; margin: 10px 0 4px; }
  .stats-sparkline-title {
    font-size: 0.65rem; letter-spacing: 1.5px; text-transform: uppercase;
    color: #999; margin-bottom: 6px;
  }

  /* ===== SHARED ENDGAME OVERLAY (Stage 3c) ===== */
  #endgameOverlay .hidden { display: none !important; }
  #egRematchStatus { font-size: 0.78rem; color: #8b7355; margin-bottom: 8px; min-height: 1.2em; text-align: center; }
  .eg-guest-prompt { background: #fef9ee; border: 1px solid #e8d9a0; border-radius: 8px; padding: 10px 12px; margin-bottom: 12px; font-size: 0.82rem; color: #5a4a1a; text-align: center; }
  .eg-guest-title { font-weight: 700; margin-bottom: 4px; }
  .eg-guest-sub { margin-bottom: 8px; }
  .eg-guest-prompt button { background: #2c2c2c; color: #f5f0e8; border: none; border-radius: 6px; padding: 6px 14px; font-size: 0.82rem; cursor: pointer; width: 100%; }

  /* ===== SHARED BADGES / LINKS (Stage 3c) ===== */
  .unranked-badge { text-align: center; margin: 2px 0 4px; font-size: 0.68rem; letter-spacing: 1.5px; text-transform: uppercase; color: #8b7355; font-weight: 600; }
  .unranked-badge-invite { margin: 0 0 8px; }
  footer .footer-link { color: #aaa; text-decoration: none; margin: 0 8px; }
  footer .footer-link:hover { color: #666; }
