/* =========================================================================
    BASE SYSTEM RESETS & APPARATUS
   ========================================================================= */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    min-height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
}

:root {
    --peter-theme: #15AFD1;
    --jadey-theme: #FFD1DC;
    --peter-theme-text: #FFFFFF;
    --jadey-theme-text: #111111;
    --theme-color: #15AFD1;
    --theme-text-color: #FFFFFF;
    --other-theme-color: #FFD1DC;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #000000;
    color: #FFFFFF;
    display: flex;
    align-items: stretch;
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
}

.app-container {
    position: fixed;
    top: var(--viewport-top, 0px);
    left: 0;
    width: 100%;
    min-width: 0;
    height: 100vh;
    height: 100svh;
    height: 100dvh;
    height: calc(var(--vh, 1vh) * 100); /* Precise mobile height variable */
    background-color: #000000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
}

.keyboard-open .app-container { padding-bottom: 0; }
input, textarea, select { font-size: 16px; }

header {
    background-color: #0A0F14;
    padding: 16px;
    text-align: center;
    border-bottom: 1px solid #161B22;
}

h1 {
    font-size: 22px;
    color: #FFFFFF;
    letter-spacing: 0.5px;
}

main {
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
}

/* =========================================================================
    SCREEN STATE & VISIBILITY CORE
   ========================================================================= */
.screen {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    width: 100%;
    justify-content: center; /* Centers onboarding elements perfectly */
}

.hidden {
    display: none !important;
}

#login-screen,
#welcome-container,
#game-screen {
    padding: 16px;
}

/* =========================================================================
    GLOBAL BUTTONS & INTERACTION SURFACES
   ========================================================================= */
button {
    font-family: inherit;
    font-size: 16px;
    font-weight: bold;
    padding: 16px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: transform 0.1s ease, opacity 0.3s ease, background-color 0.2s ease;
    touch-action: manipulation;
}

button:active {
    transform: scale(0.97);
}

button:focus-visible,
input:focus-visible,
select:focus-visible {
    outline: 3px solid #FFFFFF;
    outline-offset: 2px;
}

button:disabled {
    cursor: default;
}

.back-btn {
    background: none;
    color: #6E7681;
    padding: 0;
    text-align: left;
    font-weight: normal;
    font-size: 14px;
    align-self: flex-start;
    margin-bottom: 16px;
}

.back-btn:hover {
    color: #FFFFFF;
}

/* =========================================================================
    ONBOARDING MECHANICS (PHASES 1 & 2)
   ========================================================================= */
.greeting-small {
    font-size: 24px;
    font-weight: 600;
    color: #FFFFFF;
    margin-bottom: 8px;
    text-align: center;
}

.greeting-large {
    font-size: 42px;
    font-weight: bold;
    color: #FFFFFF;
    text-align: center;
    line-height: 1.2;
    margin-bottom: 48px;
}

.profile-buttons-wrapper {
    display: flex;
    flex-direction: column;
    gap: 16px;
    width: 100%;
}

.welcome-small {
    font-size: 28px;
    font-weight: 500;
    color: #FFFFFF;
    margin-bottom: 12px;
    text-align: center;
}

.welcome-large {
    font-size: 56px;
    font-weight: bold;
    text-align: center;
    margin: 0;
}

.profile-btn {
    width: 100%;
    height: 70px;
    font-size: 24px;
    color: #FFFFFF;
}

.peter-btn { background-color: var(--peter-theme); }
.jadey-btn { background-color: var(--jadey-theme); }

/* =========================================================================
    MAIN CORE GAMES DASHBOARD VIEW
   ========================================================================= */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    min-height: 58px;
    padding: 0 16px;
    flex-shrink: 0;
}

.auth-panel {
    width: min(100%, 420px);
    margin: 0 auto;
    padding: 24px;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
}

.auth-title {
    margin: 4px 0 24px;
    text-align: center;
    font-size: 30px;
}

.auth-form {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.auth-form label {
    color: #8B949E;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.auth-form input {
    width: 100%;
    height: 50px;
    padding: 0 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    outline: none;
    background: #05080C;
    color: #FFFFFF;
    font: inherit;
}

.auth-form input:focus {
    border-color: #FFFFFF;
}

.auth-form button {
    width: 100%;
    margin-top: 8px;
    border-radius: 8px;
    background: #58A6FF;
    color: #FFFFFF;
}

.auth-form button:disabled {
    opacity: 0.55;
}

.auth-link-btn {
    display: block;
    width: auto;
    height: auto;
    min-height: 36px;
    margin: 8px auto 0;
    padding: 6px 10px;
    background: transparent;
    color: #8B949E;
    font-size: 13px;
}

.auth-link-btn:disabled {
    opacity: 0.55;
}

.auth-status {
    min-height: 20px;
    margin-top: 14px;
    color: #8B949E;
    text-align: center;
    font-size: 13px;
}

.auth-status.error {
    color: #FF7B72;
}

.header-title {
    font-size: 22px;
    font-weight: bold;
    color: #FFFFFF;
    line-height: 1.1;
}

.header-profile-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.header-player-label {
    font-size: 10px;
    font-weight: 700;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.header-nickname {
    display: block;
    max-width: 108px;
    overflow: hidden;
    color: #FFFFFF;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.1;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pfp-placeholder {
    width: 46px;
    height: 46px;
    background-color: #101418;
    border: 2px solid transparent;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #FFFFFF;
    text-transform: uppercase;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.6);
}

.pfp-placeholder.has-photo,
.message-avatar.has-photo,
.profile-main-avatar.has-photo {
    background-position: center;
    background-size: cover;
    text-transform: none;
}

.profile-main-avatar {
    position: relative;
    flex: 0 0 100px;
    width: 100px;
    height: 100px;
    padding: 0;
    border: 3px solid transparent;
    border-radius: 50%;
    background-color: #101418;
    color: #FFFFFF;
    font-size: 42px;
    font-weight: bold;
}

.profile-main-avatar::after {
    content: "";
    position: absolute;
    right: -2px;
    bottom: -2px;
    width: 28px;
    height: 28px;
    border: 3px solid #000000;
    border-radius: 50%;
    background: #FFFFFF center / 16px no-repeat;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath fill='%230A0F14' d='M9 3 7.17 5H4a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2V7a2 2 0 0 0-2-2h-3.17L15 3H9m3 5a5 5 0 1 1 0 10 5 5 0 0 1 0-10Z'/%3E%3C/svg%3E");
}

.profile-photo-dialog {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.78);
}

.profile-photo-panel {
    width: min(100%, 360px);
    padding: 20px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
    text-align: center;
}

.profile-photo-panel h2 {
    font-size: 20px;
}

.profile-photo-preview {
    width: 180px;
    height: 180px;
    margin: 18px auto 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #FFFFFF;
    border-radius: 50%;
    background: #101418 center / cover no-repeat;
    color: #FFFFFF;
    font-size: 64px;
    font-weight: 800;
}

.profile-photo-panel p {
    min-height: 20px;
    color: #8B949E;
    font-size: 13px;
}

.profile-photo-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-top: 16px;
}

.profile-photo-actions button,
.profile-photo-choose,
.profile-photo-reset {
    border-radius: 8px;
    background: #161B22;
    color: #FFFFFF;
}

.profile-photo-choose {
    width: 100%;
    margin-top: 12px;
}

.profile-photo-actions .primary {
    background: #2EA44F;
}

.profile-photo-reset {
    width: 100%;
    margin-top: 10px;
    border: 1px solid #F85149;
    color: #FF7B72;
}

.profile-photo-panel button:disabled,
.battleship-controls button:disabled {
    cursor: default;
    opacity: 0.45;
}

.menu-prompt {
    font-size: 20px;
    font-weight: bold;
    color: #FFFFFF;
    margin: 4px 0 16px 0;
    text-align: left;
}

.games-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    padding: 10px 18px 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.home-content {
    flex: 1;
    min-height: 0;
    padding: 10px 18px 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.home-shortcut-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}

.home-shortcut-card {
    min-height: 146px;
    padding: 18px 12px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

.home-shortcut-card svg {
    width: 38px;
    height: 38px;
    fill: currentColor;
}

.home-shortcut-card span {
    font-size: 16px;
    font-weight: 800;
    text-align: center;
}

.theme-peter .home-shortcut-card { border-color: var(--peter-theme); }
.theme-jadey .home-shortcut-card { border-color: var(--jadey-theme); }

.home-greeting { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 12px 0 14px; margin-bottom: 12px; }
.home-greeting-copy { flex: 1; min-width: 0; }
.home-greeting-copy p { margin: 0 0 5px; color: #B8C2CC; font-size: 14px; line-height: 1.4; overflow-wrap: anywhere; }
.home-greeting h2 { min-width: 0; margin: 0; font-size: 27px; line-height: 1.25; overflow-wrap: anywhere; }
.home-coin-balance { flex: 0 0 auto; display: flex; align-items: center; gap: 8px; min-height: 40px; padding: 7px 10px; border: 1px solid #30363D; border-radius: 8px; background: #0A0F14; color: #FFF; font-size: 16px; font-weight: 800; font-variant-numeric: tabular-nums; }
.home-coin-balance[hidden] { display: none; }
.home-coin-balance img { width: 22px; height: 22px; object-fit: contain; }
.home-content .home-shortcut-card.realm { width: 100%; min-height: 76px; padding: 14px 18px; flex-direction: row; justify-content: flex-start; gap: 16px; background: #23132F; border-color: #81509F; color: #F2DFFF; }
.home-content .home-shortcut-card.realm span { text-align: left; }
.home-games-section { margin-top: 26px; }
.home-games-section .menu-prompt { font-size: 18px; margin-bottom: 12px; }

.games-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    width: 100%;
}

.grid-game-btn {
    background-color: #000000;
    border: 2px solid var(--theme-color);
    border-radius: 20px;
    aspect-ratio: 1 / 1; /* Forces cards to stay perfectly square, preventing squishing */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #FFFFFF;
    padding: 12px;
    text-align: center;
}

.game-card-art {
    position: relative;
    isolation: isolate;
    overflow: hidden;
    padding: 0;
    background: #9CADBA;
}

.game-card-art:has(img[src*="word-search.svg"]) { background: #F3E4A9; }
.game-card-art:has(img[src*="1010.svg"]) { background: #D9DDE0; }
.home-presence { display: flex; align-items: center; gap: 8px; font-size: 13px; color: #C8C6CE; margin: 0 0 16px; min-height: 40px; padding: 10px 12px; border: 1px solid #30363D; border-radius: 8px; background: #0D1117; }
.home-presence i { flex: 0 0 8px; width: 8px; height: 8px; border-radius: 50%; background: #85818D; }
.home-presence[data-status=online] i { background: #9EDCB0; }
.home-presence[data-status=unknown] i { background: transparent; border: 1px solid #85818D; }
.home-presence span { overflow-wrap: anywhere; min-width: 0; }
.home-last-online { display: block; margin-top: 4px; font-size: 11px; line-height: 1.5; color: #AFAAB4; }
input[type=checkbox].app-checkbox { appearance: none; -webkit-appearance: none; display: grid; place-content: center; width: 22px; height: 22px; min-height: 22px; padding: 0; margin: 0; flex: 0 0 22px; border: 1px solid #9479A7; border-radius: 5px; background: #110C18; cursor: pointer; }
input[type=checkbox].app-checkbox::after { content: ''; width: 6px; height: 11px; border: solid var(--theme-text-color, #000); border-width: 0 2px 2px 0; transform: translateY(-1px) rotate(45deg); visibility: hidden; }
input[type=checkbox].app-checkbox:checked { background: var(--theme-color); border-color: var(--theme-color); }
input[type=checkbox].app-checkbox:checked::after { visibility: visible; }
input[type=checkbox].app-checkbox:focus-visible { outline: 2px solid #FFF; outline-offset: 3px; }
input[type=checkbox].app-checkbox:disabled { opacity: .45; cursor: default; }
.game-card-art:has(img[src*="connect-four.svg"]) { background: #CEC9DA; }
.game-card-art:has(img[src*="sudoku.svg"]) { background: #91AFAC; }
.game-card-art:has(img[src*="tic-tac-toe.svg"]) { background: #A9BFC7; }

.game-card-image {
    position: absolute;
    inset: 4px 4px 42px;
    width: calc(100% - 8px);
    height: calc(100% - 46px);
    z-index: 1;
    border-radius: 0;
    object-fit: contain;
}

.game-card-art:has(img[src*="battleship.svg"]) .game-card-image,
.game-card-art:has(img[src*="rps.png"]) .game-card-image {
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.game-card-art span {
    position: absolute;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 2;
    width: 100%;
    padding: 12px 8px;
    background: rgba(0, 0, 0, 0.68);
    color: #FFFFFF;
    font-size: 17px;
    line-height: 1.15;
    backdrop-filter: blur(4px);
}

.grid-game-btn.locked {
    opacity: 0.58;
    cursor: not-allowed;
}

/* Old Legacy System Setup Fallbacks */
.game-btn {
    background-color: #0A0F14;
    color: #FFFFFF;
    border: 1px solid #161B22;
    padding: 24px;
    font-size: 18px;
    margin-bottom: 12px;
}
.game-btn:hover { background-color: #161B22; }
.game-btn.locked {
    background-color: #000000;
    color: #6E7681;
    border: 1px dashed #161B22;
    cursor: not-allowed;
}

/* =========================================================================
    GLOBAL DEVICE NAVIGATION DECK STYLING
   ========================================================================= */
.bottom-nav-bar {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    min-height: 58px;
    padding: 6px 10px;
    background-color: #0A0F14;
    border-top: 1px solid #161B22;
    width: 100%;
    flex-shrink: 0;
}

.game-bottom-nav {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    padding-inline: 4px;
}

.game-bottom-nav .nav-tab-btn {
    min-width: 0;
    font-size: 10px;
}

.nav-tab-btn {
    background-color: transparent;
    color: #07111C;
    border: none;
    font-size: 11px;
    padding: 4px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
}

.nav-tab-btn[onclick*="switchTab('home')"] { order: -1; }

.nav-tab-btn.active-tab { color: #FFFFFF; }
.nav-icon {
    width: 20px;
    height: 20px;
    flex: 0 0 20px;
    display: block;
    fill: currentColor;
}

/* Keep every tab's visible content centred within matching icon and label slots. */
.nav-tab-btn > span:not(.notification-badge) {
    display: block;
    width: 100%;
    min-height: 12px;
    line-height: 12px;
    text-align: center;
    white-space: nowrap;
}

.nav-tab-btn.active-tab .nav-icon {
    transform: translateY(-1px);
}

.mode-select-btn {
    width: 42px;
    height: 42px;
    padding: 0;
    background: #000000;
    border: 2px solid #FFFFFF;
    border-radius: 8px;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mode-select-btn svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: 12px;
    min-width: 18px;
    height: 18px;
    padding: 0 5px;
    border-radius: 999px;
    background: #FF1F1F;
    color: #FFFFFF;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    line-height: 1;
}

.app-tab-screen {
    max-height: 100%;
    overflow: hidden;
}

.messages-thread,
.notifications-list,
.modes-panel {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 10px 18px 18px;
    -webkit-overflow-scrolling: touch;
}

.message-composer {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 0 18px 14px;
    padding: 10px;
    border-radius: 20px;
    background: #0A0F14;
    flex-shrink: 0;
}

.message-composer input {
    flex: 1;
    min-width: 0;
    border: none;
    outline: none;
    background: transparent;
    color: #FFFFFF;
    font: inherit;
    font-weight: 700;
}

.message-composer input::placeholder {
    color: #FFFFFF;
    opacity: 0.95;
}

.message-composer button {
    width: 42px;
    height: 42px;
    padding: 0;
    border-radius: 14px;
    color: #FFFFFF;
    flex-shrink: 0;
}

.message-date-divider {
    margin: 14px 0;
    color: #6E7681;
    text-align: center;
    font-size: 11px;
}

.message-row {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    margin-bottom: 12px;
}

.message-row.mine {
    justify-content: flex-end;
}
.message-row.group-next { margin-bottom: 4px; }
.message-row.group-next:not(.mine) .message-bubble { border-bottom-left-radius: 4px; }
.message-row.group-previous:not(.mine) .message-bubble { border-top-left-radius: 4px; }
.message-row.mine.group-next .message-bubble { border-bottom-right-radius: 4px; }
.message-row.mine.group-previous .message-bubble { border-top-right-radius: 4px; }
.message-avatar.group-avatar-placeholder { visibility: hidden; height: 0; }
.message-action-timestamp { padding: 3px 4px 6px; color: #B8C2CC; font-size: 11px; line-height: 1.4; border-bottom: 1px solid #30363D; }

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #101820;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 800;
    flex-shrink: 0;
}

.message-stack {
    display: flex;
    flex-direction: column;
    width: fit-content;
    max-width: 76%;
    min-width: 0;
}

.message-row.mine .message-stack {
    align-items: flex-end;
}

.message-meta {
    display: flex;
    gap: 8px;
    margin: 0 6px 4px;
    color: #FFFFFF;
    font-size: 10px;
    font-weight: 700;
}

.message-meta time {
    color: #6E7681;
    font-weight: 500;
}

.message-bubble {
    width: fit-content;
    max-width: 100%;
    border-radius: 14px;
    padding: 10px 12px;
    color: #FFFFFF;
    font-size: 14px;
    font-weight: 700;
    line-height: 1.25;
    overflow-wrap: anywhere;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

.message-action-menu {
    position: fixed;
    z-index: 2500;
    width: min(304px, calc(100vw - 24px));
    box-sizing: border-box;
    max-height: calc(var(--vh, 1vh) * 100 - 24px);
    overflow-y: auto;
    display: grid;
    gap: 6px;
    padding: 8px;
    border: 1px solid #30363D;
    border-radius: 10px;
    background: #0A0F14;
    box-shadow: 0 14px 34px rgba(0,0,0,0.42);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.message-action-menu button {
    min-height: 38px;
    border-radius: 8px;
    background: #161B22;
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
    user-select: none;
    -webkit-user-select: none;
}

.message-action-menu .danger-action {
    color: #FFB4B4;
}
.message-action-menu button[hidden] { display: none; }
.message-action-buttons { display: grid; grid-template-columns: repeat(3,minmax(0,1fr)); gap: 5px; }
.received-message .message-action-buttons { grid-template-columns: 1fr; }
.message-action-buttons button { min-height: 40px; padding: 6px; }
.message-reaction-picker { display: grid; grid-template-columns: repeat(6,minmax(0,1fr)); gap: 3px; padding-bottom: 6px; border-bottom: 1px solid #30363D; }
.message-reaction-picker button { font-size: 23px; height: 44px; min-width: 0; padding: 0; border: 1px solid transparent; touch-action: none; }
.message-reaction-picker button[aria-pressed=true], .message-reaction-picker button.super-ready { border-color: var(--theme-color); background: #27333A; }
.message-reaction-picker button.super-ready { border-color: #F5D45A; box-shadow: inset 0 0 0 2px #F5D45A; }
.message-bubble-shell { position: relative; width: fit-content; max-width: 100%; }
.message-bubble-shell.has-reactions { margin-bottom: 15px; }
.message-reactions { position: absolute; bottom: -13px; left: 6px; display: flex; gap: 2px; width: max-content; z-index: 1; }
.message-row.mine .message-reactions { left: auto; right: 4px; }
.message-reaction-badge { display: inline-flex; align-items: center; justify-content: center; gap: 2px; height: 21px; min-height: 21px; min-width: 24px; padding: 1px 4px; box-sizing: border-box; background: #161B22; color: #FFF; border: 1px solid #44505C; border-radius: 11px; font-size: 13px; line-height: 1; }
.message-reaction-badge[aria-pressed=true] { border-color: var(--theme-color); }
.message-reaction-badge.super-reaction { border-color: #F5D45A; }
.message-reaction-badge small { font-size: 10px; }
.message-bubble { -webkit-touch-callout: none; }
#message-reaction-status { color: #FFB4B4; font-size: 12px; padding: 6px 12px; }
#message-reaction-status:empty { display: none; }
.message-reaction-burst { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 4000; }
.message-reaction-burst span { position: absolute; top: 50%; left: 50%; font-size: 32px; animation: reaction-burst 900ms ease-out both; }
@keyframes reaction-burst { from { transform: translate(-50%,-50%) scale(.4); opacity: 0; } 12% { opacity: 1; } 75% { opacity: 1; } to { transform: translate(calc(-50% + var(--burst-x)),calc(-50% + var(--burst-y))) rotate(var(--burst-rotation)) scale(.8); opacity: 0; } }
@media(prefers-reduced-motion:reduce) { .message-reaction-burst { display: none; } }

.notification-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
    padding: 12px;
    border-radius: 10px;
    background: #0A0F14;
    touch-action: pan-y;
    transition: transform 160ms ease, opacity 160ms ease;
}

.notification-meta {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: #6E7681;
    font-size: 10px;
}

.notification-type {
    color: #FFFFFF;
    font-weight: 800;
}

.notification-body {
    color: #FFFFFF;
    font-size: 13px;
    font-weight: 800;
    line-height: 1.25;
}

.notification-card button {
    min-width: 74px;
    padding: 9px 12px;
    border-radius: 12px;
    color: #FFFFFF;
    font-size: 13px;
}

.notification-card button[disabled] {
    background: #666666 !important;
    opacity: 1;
}

.notification-actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.notification-card .secondary-action {
    background: #30363D !important;
}

.empty-state {
    margin-top: 28px;
    color: #6E7681;
    text-align: center;
    font-size: 14px;
    font-weight: 700;
}

.profile-content,
.stats-content,
.management-content {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.management-entry {
    width: 100%;
    background: #0A0F14;
    border: 1px solid var(--theme-color);
    color: #FFFFFF;
}

.profile-theme-entry {
    width: 100%;
    padding: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    text-align: left;
}

.theme-picker-panel {
    width: min(100%, 360px);
    padding: 20px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
}

.theme-picker-panel h2 {
    margin-bottom: 16px;
    font-size: 20px;
}

.theme-colour-preview {
    width: 100%;
    height: 34px;
    margin-bottom: 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
}

.theme-colour-field {
    --theme-picker-hue: #FF0000;
    position: relative;
    width: 100%;
    height: 160px;
    overflow: hidden;
    border: 1px solid #30363D;
    border-radius: 8px;
    background:
        linear-gradient(to top, #000000, transparent),
        linear-gradient(to right, #FFFFFF, var(--theme-picker-hue));
    cursor: crosshair;
    touch-action: none;
}

.theme-colour-field-handle {
    position: absolute;
    width: 18px;
    height: 18px;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
    pointer-events: none;
    transform: translate(-50%, -50%);
}

.theme-hue-control {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 12px;
    color: #8B949E;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.theme-hue-control input {
    width: 100%;
    height: 20px;
    margin: 0;
    appearance: none;
    -webkit-appearance: none;
    border: 1px solid #30363D;
    border-radius: 999px;
    background: linear-gradient(to right, #FF0000, #FFFF00, #00FF00, #00FFFF, #0000FF, #FF00FF, #FF0000);
}

.theme-hue-control input::-webkit-slider-thumb {
    width: 18px;
    height: 18px;
    appearance: none;
    -webkit-appearance: none;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    background: #0A0F14;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

.theme-hue-control input::-moz-range-thumb {
    width: 14px;
    height: 14px;
    border: 2px solid #FFFFFF;
    border-radius: 50%;
    background: #0A0F14;
    box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.75);
}

.theme-preset-row {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    margin-bottom: 12px;
}

.theme-preset-option {
    width: 38px;
    height: 38px;
    padding: 0;
    border: 2px solid #30363D;
    border-radius: 8px;
}

.theme-preset-option.peter { background: var(--peter-theme); }
.theme-preset-option.jadey { background: var(--jadey-theme); }
.theme-preset-option:active { transform: scale(0.92); }

.theme-preset-option:focus-visible,
.theme-colour-field:focus-visible {
    outline: 2px solid #FFFFFF;
    outline-offset: 2px;
}

.theme-input-row,
.theme-rgb-grid label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    color: #8B949E;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.theme-rgb-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 12px;
}

.theme-picker-panel input[type="text"],
.theme-picker-panel input[type="number"] {
    width: 100%;
    height: 44px;
    padding: 0 10px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #05080C;
    color: #FFFFFF;
    font: inherit;
}

.theme-picker-panel .profile-photo-actions .primary {
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.profile-account-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 14px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.profile-account-summary > div {
    min-width: 0;
}

.profile-account-summary div > span {
    display: block;
    margin-bottom: 4px;
    color: #6E7681;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
}

.profile-account-summary strong {
    display: block;
    overflow: hidden;
    color: #FFFFFF;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.profile-account-summary button {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 7px;
    width: auto;
    height: 42px;
    padding: 0 12px;
    border-radius: 8px;
    background: #161B22;
    color: #FFFFFF;
    font-size: 13px;
}

.profile-account-summary svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

.account-settings-content {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
    -webkit-overflow-scrolling: touch;
}

.account-settings-group {
    padding: 16px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.account-settings-group h2 {
    margin-bottom: 8px;
    font-size: 18px;
}

.account-current-value {
    margin-bottom: 14px;
    color: #8B949E;
    font-size: 13px;
    overflow-wrap: anywhere;
}

.account-current-value strong {
    color: #FFFFFF;
}

.account-settings-group form {
    display: flex;
    flex-direction: column;
    gap: 9px;
}

.account-settings-group label {
    color: #8B949E;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.account-settings-group input {
    width: 100%;
    height: 46px;
    padding: 0 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    outline: none;
    background: #05080C;
    color: #FFFFFF;
    font: inherit;
}

.account-settings-group input:focus {
    border-color: #FFFFFF;
}

.account-settings-group button,
.account-sign-out {
    width: 100%;
    margin-top: 5px;
    border-radius: 8px;
    color: #FFFFFF;
}

.theme-peter .account-settings-group button {
    background: var(--peter-theme);
    color: var(--peter-theme-text);
}

.theme-jadey .account-settings-group button {
    background: var(--jadey-theme);
    color: var(--jadey-theme-text);
}

.account-settings-status {
    min-height: 20px;
    margin: 0;
    color: #8B949E;
    text-align: center;
    font-size: 13px;
}

.account-settings-status.error {
    color: #FF7B72;
}

.account-sign-out {
    flex: 0 0 auto;
    border: 1px solid #F85149;
    background: transparent;
    color: #FF7B72;
}

#account-settings-screen button:disabled,
#account-settings-screen input:disabled {
    opacity: 0.55;
}

.stats-content {
    flex: 1;
    padding: 10px 18px 18px;
}

.stats-content-heading {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    justify-content: space-between;
    margin-bottom: 12px;
}

.stats-content-heading .menu-prompt {
    margin: 0;
}

.stats-content-heading .stats-content-back-btn {
    width: 34px;
    height: 34px;
    padding: 0;
    flex-shrink: 0;
}

.stats-content-back-btn svg {
    width: 20px;
    height: 20px;
}

.stats-content .menu-prompt {
    margin-top: 4px;
}

.stats-category-card {
    width: 100%;
    min-height: 92px;
    margin-bottom: 12px;
    padding: 10px;
    display: grid;
    grid-template-columns: 72px minmax(0, 1fr);
    align-items: center;
    gap: 14px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    text-align: left;
}

.stats-category-card img {
    width: 72px;
    height: 72px;
    border-radius: 6px;
    object-fit: cover;
}

.stats-category-card span {
    font-size: 19px;
}

.stats-category-card.locked {
    opacity: 0.45;
}

.stats-back-btn {
    padding: 0;
    background: transparent;
    color: #8B949E;
    font-size: 13px;
}

.stats-detail-title {
    margin: 14px 0;
    font-size: 22px;
}

.stats-player-card {
    margin-bottom: 16px;
    border: 1px solid #161B22;
    border-radius: 8px;
    overflow: hidden;
    background: #0A0F14;
}

.stats-player-heading,
.stats-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
}

.stats-player-heading {
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 800;
}

.peter-stats .stats-player-heading { background: var(--peter-theme); color: var(--peter-theme-text); }
.jadey-stats .stats-player-heading { background: var(--jadey-theme); color: var(--jadey-theme-text); }

.stats-row {
    border-top: 1px solid #161B22;
    color: #C9D1D9;
    font-size: 14px;
}

.stats-row strong,
.stats-player-heading strong {
    font-size: 20px;
}

.management-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 20px;
}

.management-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 14px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.management-group h2 {
    margin-bottom: 2px;
    font-size: 17px;
}

.management-content label {
    color: #8B949E;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.management-content select {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    font: inherit;
    font-weight: 700;
}

.management-content button {
    width: 100%;
    border-radius: 8px;
    background: #161B22;
    color: #FFFFFF;
    text-align: left;
}

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

.management-actions button {
    text-align: center;
}

.management-subgroup {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.management-content .danger-action {
    margin-top: 12px;
    border: 1px solid #F85149;
    color: #FF7B72;
}

.management-status {
    min-height: 20px;
    color: #8B949E;
    font-size: 13px;
}

/* =========================================================================
    WORD SEARCH
   ========================================================================= */
.word-search-screen {
    max-height: 100%;
    overflow: hidden;
}

.word-search-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding: 12px 14px;
    overflow-y: auto;
}

.word-search-lobby {
    flex: 1 1 auto;
    min-height: 0;
    padding: 20px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow-y: auto;
}

.word-search-lobby-panel {
    width: 100%;
    max-width: 380px;
    padding: 24px 18px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: linear-gradient(180deg, #0E151C 0%, #080D12 100%);
    box-shadow: 0 18px 48px #0008, inset 0 1px 0 rgba(255,255,255,.04);
    text-align: center;
}

.word-search-lobby-mode {
    display: inline-block;
    margin-bottom: 12px;
    padding: 5px 9px;
    border: 1px solid color-mix(in srgb, var(--theme-color) 55%, #30363D);
    border-radius: 999px;
    color: var(--theme-color);
    font-size: 11px;
    font-weight: 900;
    text-transform: uppercase;
}

.word-search-lobby-panel h2 { margin: 0 0 8px; font-size: 25px; }
.word-search-lobby-panel p { margin: 0 auto; max-width: 290px; color: #9BA6B2; font-size: 13px; font-weight: 700; line-height: 1.45; }
.word-search-lobby-status { min-height: 38px; margin: 18px 0 10px; color: #C9D1D9; font-size: 13px; font-weight: 800; }
.word-search-lobby-primary, .word-search-lobby-settings { width: 100%; min-height: 52px; border-radius: 8px; font: inherit; font-weight: 900; }
.word-search-lobby-primary { background: var(--theme-color); color: var(--theme-text-color); }
.word-search-lobby-primary:disabled { background: #30363D; color: #8B949E; }
.word-search-lobby-settings { margin-top: 10px; border: 1px solid #30363D; background: #0A0F14; color: #FFF; }

@media (prefers-reduced-motion: no-preference) {
    .word-search-lobby:not(.hidden) .word-search-lobby-panel { animation: submenu-rise 200ms ease-out both; }
}

.word-search-status {
    min-height: 20px;
    color: #8B949E;
    font-size: 12px;
    font-weight: 800;
}

.word-search-words {
    width: 100%;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px 10px;
    min-height: 42px;
}

.word-search-words span {
    color: #FFFFFF;
    font-size: 12px;
    font-weight: 800;
}

.word-search-words span.found {
    color: #6E7681;
    text-decoration: line-through;
}

.word-search-current-word {
    width: 100%;
    min-height: 34px;
    padding: 8px 10px;
    border-radius: 6px;
    background: #0A0F14;
    color: #FFFFFF;
    text-align: center;
    font-size: 15px;
    font-weight: 800;
}

.word-search-grid {
    --word-grid-size: 7;
    width: min(100%, 420px);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(var(--word-grid-size), minmax(0, 1fr));
    grid-template-rows: repeat(var(--word-grid-size), minmax(0, 1fr));
    gap: 3px;
    touch-action: none;
    user-select: none;
}

.word-search-grid.disabled {
    pointer-events: none;
    opacity: 0.55;
}

.word-search-grid.concealed .word-search-cell {
    color: transparent;
    text-shadow: none;
}

.word-search-cell {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid #30363D;
    border-radius: 5px;
    background: #0A0F14;
    color: #FFFFFF;
    font-size: 18px;
    font-weight: 900;
    line-height: 1;
}

.word-search-cell.preview {
    border-color: #FFFFFF;
    background: #30363D;
}

.word-search-cell.found-cell {
    border-color: var(--found-colour);
    background: color-mix(in srgb, var(--found-colour) 72%, #000000);
    color: #FFFFFF;
}

.word-search-result {
    width: 100%;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
}

.word-search-result button {
    padding: 9px 12px;
    border-radius: 6px;
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.word-search-result > div {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.word-search-result-note {
    color: #8B949E;
    font-size: 12px;
}

.ai-progress {
    width: 100%;
    height: 8px;
    margin-top: 8px;
    overflow: hidden;
    border-radius: 999px;
    background: #161B22;
}

.ai-progress span {
    display: block;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, var(--other-theme-color), var(--theme-color));
    transition: width 0.35s ease;
}

.word-search-settings,
.sudoku-settings {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 20px;
}

.word-search-settings label,
.sudoku-settings label {
    color: #8B949E;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
}

.word-search-settings select,
.sudoku-settings select {
    width: 100%;
    height: 50px;
    padding: 0 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    font: inherit;
    font-weight: 800;
}

.word-search-settings > button,
.sudoku-settings > button {
    width: 100%;
    margin-top: 8px;
    border-radius: 8px;
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.word-stats-player {
    margin-bottom: 16px;
    overflow: hidden;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.word-stats-player > h3 {
    padding: 12px 14px;
    color: #FFFFFF;
}

.word-stats-player.peter > h3 { background: var(--peter-theme); color: var(--peter-theme-text); }
.word-stats-player.jadey > h3 { background: var(--jadey-theme); color: var(--jadey-theme-text); }

.word-stats-mode {
    padding: 10px 12px;
    border-top: 1px solid #161B22;
}

.word-stats-mode h4 {
    margin-bottom: 6px;
    color: #FFFFFF;
    font-size: 14px;
}

.word-stats-row {
    display: grid;
    grid-template-columns: 42px repeat(4, minmax(0, 1fr));
    gap: 6px;
    padding: 5px 0;
    color: #8B949E;
    font-size: 10px;
}

.word-stats-row.ai-stats-row {
    grid-template-columns: 42px 42px repeat(4, minmax(0, 1fr));
}

.word-stats-row.sudoku-ai-stats-row {
    grid-template-columns: 68px 42px repeat(3, minmax(0, 1fr));
}

.word-stats-row strong {
    color: #FFFFFF;
}

.word-stats-head {
    padding-bottom: 7px;
    border-bottom: 1px solid #21262D;
    color: #6E7681;
    font-weight: 800;
}

/* =========================================================================
    BATTLESHIP
   ========================================================================= */
.battleship-screen {
    max-height: 100%;
    overflow: hidden;
    position: relative;
    background-color: #064E67;
    background-image:
        linear-gradient(172deg, transparent 0 42%, rgba(255,255,255,0.08) 43% 46%, transparent 47% 100%),
        linear-gradient(188deg, transparent 0 56%, rgba(0,20,40,0.18) 57% 61%, transparent 62% 100%),
        linear-gradient(180deg, #087E9B 0%, #075D78 46%, #043B52 100%);
    background-size: 180px 74px, 230px 96px, 100% 100%;
    animation: ocean-drift 12s linear infinite;
}

@keyframes ocean-drift {
    from { background-position: 0 0, 0 0, 0 0; }
    to { background-position: 180px 0, -230px 0, 0 0; }
}

@media (prefers-reduced-motion: reduce) {
    .battleship-screen {
        animation: none;
    }
}

.battleship-screen .dashboard-header,
.battleship-nav {
    border-color: rgba(255, 255, 255, 0.4);
}

.battleship-content {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    overflow-y: auto;
}

.battleship-status {
    flex: 0 0 auto;
    line-height: 1.4;
    overflow-wrap: anywhere;
    width: 100%;
    min-height: 36px;
    padding: 8px 10px;
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 8px;
    background: rgba(0, 20, 30, 0.72);
    color: #FFFFFF;
    text-align: center;
    font-size: 15px;
    font-weight: 800;
}

.battleship-view-toggle {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    padding: 3px;
    border: 1px solid rgba(255,255,255,0.28);
    border-radius: 8px;
    background: rgba(0, 20, 30, 0.72);
}

.battleship-view-toggle button {
    padding: 9px 6px;
    border-radius: 6px;
    background: transparent;
    color: #90A4AE;
    font-size: 12px;
}

.battleship-view-toggle button.active {
    background: #FFFFFF;
    color: #073B4C;
}

.battleship-fleet {
    width: 100%;
    align-items: center;
    align-content: center;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 5px;
    flex-shrink: 0;
}

.battleship-fleet .fleet-ship {
    display: inline-flex;
    align-items: center;
    line-height: 1.25;
    white-space: nowrap;
    padding: 5px 7px;
    border: 1px solid rgba(255,255,255,0.25);
    border-radius: 6px;
    background: rgba(0, 20, 30, 0.68);
    color: #FFFFFF;
    font-size: 9px;
    font-weight: 800;
}

.battleship-fleet .fleet-ship.sunk {
    border-color: #FF6B6B;
    color: #FFB4B4;
    text-decoration: line-through;
}

.battleship-board {
    width: min(100%, 360px);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(8, minmax(0, 1fr));
    grid-template-rows: repeat(8, minmax(0, 1fr));
    gap: 3px;
    padding: 6px;
    border: 2px solid rgba(255,255,255,0.55);
    border-radius: 8px;
    background: rgba(0, 20, 30, 0.52);
    box-shadow: 0 8px 24px rgba(0,0,0,0.32);
}

.battleship-cell {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 4px;
    background: #0E7490;
    color: #FFFFFF;
    font-size: 20px;
    line-height: 1;
    touch-action: none;
}

.battleship-cell:not(:disabled):active {
    background: #22B8CF;
}

.battleship-cell.ship {
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.72);
}

.ship-carrier { background-color: #52616B !important; }
.ship-cruiser { background-color: #64627A !important; }
.ship-submarine { background-color: #496B68 !important; }
.ship-destroyer { background-color: #766858 !important; }
.ship-patrol { background-color: #765F6B !important; }

.battleship-cell.dragging-origin {
    opacity: 0.28;
}

.battleship-cell.miss {
    background: #155E75;
    color: #BAE6FD;
}

.battleship-cell.hit {
    background: #DC2626;
    color: #FFFFFF;
}

.battleship-cell.sunk-cell {
    background: #7F1D1D;
    box-shadow: inset 0 0 0 2px #FCA5A5;
}

.battleship-cell:disabled {
    opacity: 1;
}

.battleship-waiting {
    grid-column: 1 / -1;
    align-self: center;
    color: #FFFFFF;
    text-align: center;
    font-weight: 800;
}

.battleship-drag-ghost {
    position: fixed;
    z-index: 3000;
    display: grid;
    gap: 3px;
    pointer-events: none;
    opacity: 0.94;
    transform: translate(-50%, -50%) scale(1.04);
    filter: drop-shadow(0 14px 16px rgba(0,0,0,0.45));
}

.battleship-drag-ghost.horizontal {
    grid-auto-flow: column;
    grid-auto-columns: 34px;
    grid-template-rows: 34px;
}

.battleship-drag-ghost.vertical {
    grid-template-columns: 34px;
    grid-auto-rows: 34px;
}

.battleship-drag-ghost span {
    border: 1px solid rgba(255,255,255,0.58);
    border-radius: 5px;
    box-shadow: inset 0 0 0 2px rgba(255,255,255,0.5);
}

.battleship-controls {
    width: 100%;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

.battleship-controls .full-width {
    grid-column: 1 / -1;
}

.battleship-controls button {
    padding: 12px;
    border: 1px solid rgba(255,255,255,0.24);
    border-radius: 8px;
    background: rgba(0, 20, 30, 0.8);
    color: #FFFFFF;
}

.battleship-controls button.primary {
    background: #2EA44F;
}

.battleship-controls button.danger {
    border-color: #F85149;
    color: #FFB4B4;
}

.battleship-stat-card {
    margin-bottom: 14px;
    overflow: hidden;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.battleship-stat-card h3 {
    padding: 12px 14px;
    color: #FFFFFF;
}

.battleship-stat-card.peter h3 { background: var(--peter-theme); color: var(--peter-theme-text); }
.battleship-stat-card.jadey h3 { background: var(--jadey-theme); color: var(--jadey-theme-text); }

.battleship-stat-card div {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid #161B22;
    color: #C9D1D9;
}

/* =========================================================================
    CONNECT FOUR
   ========================================================================= */
.connect-four-screen {
    max-height: 100%;
    overflow: hidden;
    background:
        radial-gradient(circle at 20% 18%, rgba(88,166,255,0.12), transparent 30%),
        radial-gradient(circle at 82% 74%, rgba(182,133,189,0.12), transparent 32%),
        #05080C;
}

.connect-four-content {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    overflow-y: auto;
}

.connect-four-status {
    width: 100%;
    min-height: 44px;
    padding: 12px;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
    text-align: center;
    font-size: 15px;
    font-weight: 800;
}

.connect-four-turns {
    width: 100%;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.connect-four-player {
    min-width: 0;
    padding: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
    color: #8B949E;
    font-size: 12px;
}

.connect-four-player.active {
    border-color: #FFFFFF;
    color: #FFFFFF;
    box-shadow: 0 0 0 1px rgba(255,255,255,0.25);
}

.connect-four-player strong {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.connect-four-token {
    width: 18px;
    height: 18px;
    flex: 0 0 18px;
    border: 2px solid rgba(255,255,255,0.72);
    border-radius: 50%;
}

.token-peter {
    background: var(--peter-theme) !important;
}

.token-jadey {
    background: var(--jadey-theme) !important;
}

.connect-four-board {
    width: min(100%, 420px);
    aspect-ratio: 7 / 6;
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    grid-template-rows: repeat(6, minmax(0, 1fr));
    gap: 5px;
    padding: 8px;
    border: 2px solid #6AA9D8;
    border-radius: 8px;
    background: #247AA8;
    box-shadow: 0 12px 24px rgba(0,0,0,0.38);
}

.connect-four-cell {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 2px solid rgba(0,0,0,0.2);
    border-radius: 50%;
    background: #05080C;
    box-shadow: inset 0 3px 5px rgba(0,0,0,0.52);
}

.connect-four-cell:not(:disabled):active {
    transform: translateY(2px);
    filter: brightness(1.15);
}

.connect-four-cell.last-token {
    animation: token-drop 0.42s cubic-bezier(0.22, 0.78, 0.28, 1.15);
}

.connect-four-cell.winning-token {
    box-shadow: inset 0 0 0 4px #FFFFFF, 0 0 14px rgba(255,255,255,0.85);
    animation: winning-token 0.85s ease-in-out infinite alternate;
}

.connect-four-controls {
    width: 100%;
    display: grid;
}

.connect-four-controls button {
    width: 100%;
    padding: 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
}

.connect-four-controls button.primary {
    background: #2EA44F;
}

.connect-four-controls button.danger {
    border-color: #F85149;
    color: #FFB4B4;
}

.connect-four-stat-card {
    margin-bottom: 14px;
    overflow: hidden;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.connect-four-stat-card h3 {
    padding: 12px 14px;
}

.connect-four-stat-card.peter h3 { background: var(--peter-theme); color: var(--peter-theme-text); }
.connect-four-stat-card.jadey h3 { background: var(--jadey-theme); color: var(--jadey-theme-text); }

.connect-four-stat-card div {
    display: flex;
    justify-content: space-between;
    padding: 10px 14px;
    border-top: 1px solid #161B22;
    color: #C9D1D9;
}

.sudoku-screen {
    background: #05070A;
}

.sudoku-content {
    flex: 1;
    min-height: 0;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    overflow-y: auto;
}

.sudoku-status {
    width: 100%;
    min-height: 38px;
    padding: 9px 10px;
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 8px;
    background: #0B1117;
    color: #FFFFFF;
    text-align: center;
    font-size: 14px;
    font-weight: 800;
}

.sudoku-board {
    width: min(100%, 350px);
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(9, minmax(0, 1fr));
    grid-template-rows: repeat(9, minmax(0, 1fr));
    border: 3px solid #FFFFFF;
    border-radius: 8px;
    overflow: hidden;
    background: #FFFFFF;
}

.sudoku-cell {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border-right: 1px solid #2A3441;
    border-bottom: 1px solid #2A3441;
    border-radius: 0;
    background: #0B1117;
    color: var(--theme-color);
    font-size: 18px;
    font-weight: 900;
}

.sudoku-cell.given {
    background: #111A24;
    color: #FFFFFF;
}

.sudoku-cell.selected {
    background: rgba(88, 166, 255, 0.28);
    box-shadow: inset 0 0 0 2px var(--theme-color);
}

.sudoku-cell.block-right {
    border-right-width: 3px;
    border-right-color: #FFFFFF;
}

.sudoku-cell.block-bottom {
    border-bottom-width: 3px;
    border-bottom-color: #FFFFFF;
}

.sudoku-board.concealed .sudoku-cell {
    color: transparent;
}

.sudoku-board.disabled .sudoku-cell {
    pointer-events: none;
    opacity: 0.82;
}

.sudoku-pad {
    width: min(100%, 350px);
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 7px;
}

.sudoku-pad button,
.sudoku-result button {
    min-height: 38px;
    border-radius: 8px;
    background: var(--theme-color);
    color: var(--theme-text-color);
    font-weight: 900;
}

.sudoku-pad .sudoku-erase {
    grid-column: span 2;
    background: #161B22;
    color: #FFFFFF;
}

.sudoku-pad .sudoku-clear {
    grid-column: span 3;
    background: #161B22;
    color: #FFFFFF;
}

.sudoku-result {
    width: min(100%, 350px);
    padding: 9px;
    border-radius: 8px;
    background: #0B1117;
    color: #FFFFFF;
    text-align: center;
    font-weight: 800;
}

.sudoku-result button {
    width: 100%;
    margin-top: 8px;
}

.sudoku-complete .sudoku-content {
    gap: 7px;
}

/* =========================================================================
    TIC-TAC-TOE + ROCK PAPER SCISSORS
   ========================================================================= */
.duel-game-screen {
    max-height: 100%;
    overflow: hidden;
}

.duel-game-content {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 14px 18px;
    overflow-y: auto;
}

.duel-status {
    min-height: 24px;
    color: #C9D1D9;
    font-size: 14px;
    font-weight: 800;
    text-align: center;
}

.duel-controls {
    width: min(100%, 340px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.duel-controls button {
    min-height: 48px;
    border-radius: 8px;
    background: #161B22;
    color: #FFFFFF;
}

.duel-controls button.primary {
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.duel-controls button.danger {
    border: 1px solid #F85149;
    background: transparent;
    color: #FF7B72;
}

.duel-controls button:only-child {
    grid-column: 1 / -1;
}

.duel-settings {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 18px;
}

.duel-settings label {
    color: #8B949E;
    font-size: 12px;
    font-weight: 800;
    text-transform: uppercase;
}

.duel-settings select {
    width: 100%;
    height: 48px;
    padding: 0 12px;
    border: 1px solid #30363D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    font: inherit;
    font-weight: 700;
}

.duel-settings > button {
    border-radius: 8px;
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.ttt-board {
    width: min(82vw, 330px);
    max-width: 100%;
    aspect-ratio: 1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 8px;
}

.ttt-cell {
    min-width: 0;
    min-height: 0;
    padding: 0;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
    font-size: clamp(34px, 16vw, 64px);
    font-weight: 900;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.12s ease, border-color 0.18s ease, background-color 0.18s ease;
}

.ttt-cell:not(:disabled):active {
    transform: scale(0.94);
}

.ttt-cell.own-mark {
    color: var(--theme-color);
    border-color: var(--theme-color);
    animation: mark-pop 0.2s ease-out;
}

.ttt-cell.opponent-mark {
    color: var(--other-theme-color);
    border-color: var(--other-theme-color);
    animation: mark-pop 0.2s ease-out;
}

.ttt-cell.winning-cell {
    background: rgba(255, 255, 255, 0.08);
    animation: winning-token 0.85s ease-in-out infinite alternate;
}

.rps-reveal {
    width: min(100%, 360px);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.rps-reveal-card {
    min-height: 132px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
}

.rps-reveal-card.own-choice {
    border-color: var(--theme-color);
}

.rps-reveal-card.opponent-choice {
    border-color: var(--other-theme-color);
}

.rps-reveal-card strong {
    color: #8B949E;
    font-size: 11px;
    text-transform: uppercase;
}

.rps-reveal-card span {
    font-size: 48px;
    line-height: 1;
}

.rps-reveal-card.revealed span {
    animation: mark-pop 0.22s ease-out;
}

.rps-reveal-card .rps-ready-mark {
    position: relative;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    border: 2px solid var(--rps-ready-colour);
    border-radius: 50%;
    background: color-mix(in srgb, var(--rps-ready-colour) 14%, #0A0F14);
    box-shadow: 0 0 12px color-mix(in srgb, var(--rps-ready-colour) 14%, transparent);
}
.rps-ready-mark::after {
    content: '';
    position: absolute;
    width: 10px;
    height: 19px;
    left: 16px;
    top: 9px;
    border: solid var(--rps-ready-colour);
    border-width: 0 3px 3px 0;
    border-radius: 1px;
    transform: rotate(45deg);
}
.rps-ready-mark.newly-ready { animation: mark-pop 0.22s ease-out; }
@media (prefers-reduced-motion: reduce) { .rps-ready-mark.newly-ready { animation: none; } }

.rps-choices {
    width: min(100%, 360px);
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.rps-choice {
    min-height: 86px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 5px;
    padding: 10px 4px;
    border: 1px solid #21262D;
    border-radius: 8px;
    background: #0A0F14;
    color: #FFFFFF;
}

.rps-choice span {
    font-size: 32px;
    line-height: 1;
}

.rps-choice strong {
    font-size: 12px;
}

.rps-choice.selected {
    border-color: var(--theme-color);
    box-shadow: inset 0 0 0 1px var(--theme-color);
}

.duel-stat-card {
    margin-bottom: 16px;
    border: 1px solid #161B22;
    border-radius: 8px;
    overflow: hidden;
    background: #0A0F14;
}

.duel-stat-card h3 {
    padding: 12px 14px;
    background: #161B22;
    font-size: 17px;
}

.duel-stat-card.peter h3 {
    background: var(--peter-theme);
    color: var(--peter-theme-text);
}

.duel-stat-card.jadey h3 {
    background: var(--jadey-theme);
    color: var(--jadey-theme-text);
}

.duel-stat-mode {
    padding: 0;
    border-top: 1px solid #161B22;
}

.duel-stat-mode h4 {
    margin: 0;
    padding: 12px 14px;
    font-size: 14px;
}

.duel-stat-mode .stats-row {
    margin: 0;
}

@keyframes token-drop {
    from { opacity: 0.25; transform: translateY(-250%); }
    72% { transform: translateY(8%); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes winning-token {
    from { filter: brightness(1); }
    to { filter: brightness(1.3); }
}

@keyframes mark-pop {
    0% { transform: scale(0.65); opacity: 0.2; }
    80% { transform: scale(1.08); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

.grid-game-btn,
.stats-category-card {
    transition: transform 0.18s ease, filter 0.18s ease, border-color 0.18s ease;
}

.grid-game-btn:not(:disabled):hover,
.stats-category-card:not(:disabled):hover {
    filter: brightness(1.08);
}

.grid-game-btn:not(:disabled):active,
.stats-category-card:not(:disabled):active {
    transform: scale(0.97);
}

.message-row {
    animation: item-rise 0.22s ease-out both;
}

.notification-card,
.stats-player-card,
.word-stats-player,
.battleship-stat-card,
.connect-four-stat-card {
    animation: item-rise 0.26s ease-out both;
}

.notification-badge:not(.hidden) {
    animation: badge-pop 0.28s cubic-bezier(0.22, 0.8, 0.28, 1.3);
}

.nav-tab-btn .nav-icon {
    transition: transform 0.18s ease;
}

.nav-tab-btn:active .nav-icon {
    transform: scale(0.86);
}

@keyframes item-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes badge-pop {
    from { transform: scale(0.5); }
    to { transform: scale(1); }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
    }
}

.mode-option-btn {
    width: 100%;
    margin-bottom: 14px;
    padding: 16px;
    border: 1px solid #1F2933;
    border-radius: 8px;
    background: linear-gradient(180deg, #0E151C 0%, #080D12 100%);
    color: #FFFFFF;
    text-align: left;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.mode-option-btn.active-mode {
    border-color: currentColor;
    box-shadow: inset 0 0 0 1px currentColor;
}

.mode-option-btn span,
.mode-option-btn small {
    display: block;
}

.mode-option-btn span {
    font-size: 20px;
    margin-bottom: 5px;
}

.mode-option-btn small {
    color: #8B949E;
    font-size: 12px;
}

.number-guess-menu-area {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    padding: 18px;
    -webkit-overflow-scrolling: touch;
}

.number-guess-menu-area.number-guess-pause-view {
    position: absolute;
    top: 58px;
    right: 0;
    bottom: 58px;
    left: 0;
    z-index: 7;
    display: flex;
    align-items: center;
    justify-content: center;
    background:
        linear-gradient(rgba(0, 0, 0, 0.52), rgba(0, 0, 0, 0.72)),
        radial-gradient(circle at 50% 28%, rgba(255, 255, 255, 0.1), transparent 44%);
    backdrop-filter: blur(8px);
    animation: pause-screen-fade 0.22s ease-out both;
}

.number-guess-menu-area.number-guess-submenu-view {
    background: #000000;
}

.number-guess-menu-area.number-guess-submenu-view .number-guess-menu-panel {
    animation: submenu-rise 0.2s ease-out both;
}

.number-guess-menu-panel {
    width: 100%;
}

.number-guess-menu-heading {
    margin-bottom: 8px;
    color: #FFFFFF;
    font-size: 28px;
}

.number-guess-menu-heading.centred {
    text-align: center;
}

.number-guess-menu-subtitle {
    max-width: 300px;
    margin: 0 auto 18px;
    color: #C9D1D9;
    text-align: center;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.35;
}

.number-guess-submenu-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 18px;
}

.number-guess-submenu-heading h2 {
    color: #FFFFFF;
    font-size: 28px;
}

.number-guess-submenu-heading p {
    margin-top: 4px;
    color: #8B949E;
    font-size: 14px;
    font-weight: 800;
}

.pause-panel {
    position: relative;
    justify-content: center;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 360px;
    animation: pause-panel-in 0.24s ease-out both;
}

.sound-effects-toggle {
    position: absolute;
    top: -2px;
    right: 0;
    width: 38px;
    height: 38px;
    padding: 8px;
    border: 1px solid rgba(255, 255, 255, 0.16);
    border-radius: 8px;
    background: rgba(10, 15, 20, 0.72);
    color: #FFFFFF;
}

.sound-effects-toggle svg {
    width: 100%;
    height: 100%;
    fill: currentColor;
}

.sound-effects-toggle:active {
    transform: scale(0.92);
}

.profile-sound-setting, .sound-settings-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}
.profile-sound-setting { padding: 12px 14px; border-block: 1px solid #30363D; cursor: pointer; }
.profile-sound-setting small { display: block; margin-top: 4px; font-size: 12px; color: #9BA6B2; }
.profile-sound-setting input {
    appearance: none;
    -webkit-appearance: none;
    position: relative;
    width: 48px;
    height: 28px;
    flex: 0 0 48px;
    border: 1px solid #6E7681;
    border-radius: 16px;
    background: #30363D;
    cursor: pointer;
}
.profile-sound-setting input::after { content: ''; position: absolute; width: 20px; height: 20px; top: 3px; left: 3px; border-radius: 50%; background: #FFF; transition: transform 140ms ease; }
.profile-sound-setting input:checked { background: var(--theme-color); }
.profile-sound-setting input:checked::after { transform: translateX(20px); background: var(--theme-text-color); }
.profile-sound-setting input:focus-visible { outline: 2px solid #FFF; outline-offset: 4px; }
.sound-settings-row { padding-bottom: 12px; margin-bottom: 12px; border-bottom: 1px solid #30363D; }
.sound-settings-row .sound-effects-toggle { position: static; width: 38px; height: 38px; min-height: 38px; flex: 0 0 38px; padding: 8px; margin: 0; background: #0A0F14; color: #FFF; }

@media (prefers-reduced-motion: no-preference) {
    .home-shortcut-card:active, .profile-theme-entry:active, .theme-preset-option:active { transform: scale(.98); }
    .profile-photo-dialog:not(.hidden) > div, .message-action-menu:not(.hidden) { animation: dialog-appear 160ms ease-out; }
}
@keyframes dialog-appear { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }

.pause-option-btn {
    width: 100%;
    min-height: 74px;
    padding: 16px 18px;
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 8px;
    background: rgba(10, 15, 20, 0.72);
    color: #FFFFFF;
    backdrop-filter: blur(10px);
    box-shadow:
        0 16px 38px rgba(0, 0, 0, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.04);
    text-align: left;
}

.pause-option-btn.primary {
    background: var(--theme-color);
    color: var(--theme-text-color);
}

.pause-option-btn span,
.pause-option-btn small {
    display: block;
}

.pause-option-btn span {
    margin-bottom: 5px;
    font-size: 20px;
}

.pause-option-btn small {
    color: #8B949E;
    font-size: 12px;
}

.pause-option-btn.primary small {
    color: currentColor;
    opacity: 0.78;
}

@keyframes pause-screen-fade {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes pause-panel-in {
    from { opacity: 0; transform: scale(0.985); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes submenu-rise {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* =========================================================================
    RUNTIME THEMATIC ISOLATION ENGINE (PETER VS JADEY SETUP)
   ========================================================================= */

/* Main Base Color Maps */
.theme-peter .pfp-placeholder,
.theme-peter #profile-main-avatar { border-color: var(--peter-theme); }

.theme-jadey .pfp-placeholder,
.theme-jadey #profile-main-avatar { border-color: var(--jadey-theme); }

/* Dashboard Content Grid Borders */
.theme-peter .grid-game-btn { border-color: var(--peter-theme); }
.theme-jadey .grid-game-btn { border-color: var(--jadey-theme); }

/* Shared Interface Module Color Overrides */
.header-peter, .nav-peter { background-color: var(--peter-theme) !important; color: var(--peter-theme-text); }
.header-jadey, .nav-jadey { background-color: var(--jadey-theme) !important; color: var(--jadey-theme-text); }
.header-peter .header-title,
.header-peter .header-player-label,
.header-peter .header-nickname,
.nav-peter .nav-tab-btn,
.nav-peter .nav-icon {
    color: var(--peter-theme-text);
    fill: var(--peter-theme-text);
}
.header-jadey .header-title,
.header-jadey .header-player-label,
.header-jadey .header-nickname,
.nav-jadey .nav-tab-btn,
.nav-jadey .nav-icon {
    color: var(--jadey-theme-text);
    fill: var(--jadey-theme-text);
}

.theme-peter .message-composer button,
.theme-peter .notification-card button { background-color: var(--peter-theme); color: var(--peter-theme-text); }

.theme-jadey .message-composer button,
.theme-jadey .notification-card button { background-color: var(--jadey-theme); color: var(--jadey-theme-text); }

.theme-peter .mode-option-btn.active-mode { border-color: var(--peter-theme); }
.theme-jadey .mode-option-btn.active-mode { border-color: var(--jadey-theme); }

.theme-peter .number-entry input:focus { border-color: var(--peter-theme); }
.theme-jadey .number-entry input:focus { border-color: var(--jadey-theme); }

/* =========================================================================
    1 TO 10 GAME WORKSPACE DESIGN SYSTEM
   ========================================================================= */
.pad-num-btn {
    background-color: #0A0F14;
    border: 2px solid transparent;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    cursor: pointer;
    transition: background-color 0.15s, transform 0.1s, border-color 0.15s;
}

.pad-num-btn:active {
    transform: scale(0.96);
}

/* Clean, Non-conflicting Number Selection Outlines */
.theme-peter .pad-num-btn.selected-key {
    border-color: var(--peter-theme) !important;
    color: var(--peter-theme) !important;
}

.theme-jadey .pad-num-btn.selected-key {
    border-color: var(--jadey-theme) !important;
    color: var(--jadey-theme) !important;
}

/* Base Guess Card Borders */
#game-1-to-10-screen .your-guess-border,
#game-1-to-10-screen .their-target-border {
    border: 1px solid #161B22;
    background-color: #0A0F14 !important;
}

/* In-Game Interactive Guess Card Highlight Borders */
.theme-peter #flip-inner-guess .your-guess-border { border-color: var(--peter-theme); }
.theme-peter #flip-inner-target .their-target-border { border-color: var(--jadey-theme); }

.theme-jadey #flip-inner-guess .your-guess-border { border-color: var(--jadey-theme); }
.theme-jadey #flip-inner-target .their-target-border { border-color: var(--peter-theme); }

/* Dynamic Context Driven Action Submit Elements */
#game-action-submit-strip {
    width: 100%;
    height: 64px;
    background-color: #0A0F14;
    border: none;
    border-radius: 12px;
    font-size: 24px;
    font-weight: bold;
    color: #FFFFFF;
    transition: background-color 0.2s ease, color 0.2s ease;
}

#game-action-submit-strip.ready-to-submit {
    background-color: #2EA44F !important;
    color: #FFFFFF;
    cursor: pointer;
}

.game-choice-pad {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(5, 1fr);
    gap: 12px;
    flex: 1;
    width: 100%;
    min-height: 0;
    margin: 8px 0;
}

.game-choice-pad.colour-mode {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(4, 1fr);
}

.game-choice-pad.keyboard-mode {
    display: flex;
    align-items: center;
    justify-content: center;
}

.number-entry {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.number-entry input {
    width: 100%;
    height: 78px;
    border: 2px solid #161B22;
    border-radius: 14px;
    background: #0A0F14;
    color: #FFFFFF;
    text-align: center;
    font-size: 32px;
    font-weight: 800;
    outline: none;
}

.number-entry input:focus {
    border-color: currentColor;
}

.colour-tile {
    min-width: 0;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 12px;
    color: #FFFFFF;
    font-size: 11px !important;
    font-weight: 800;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.colour-tile.light-label {
    color: #111111;
    text-shadow: none;
}

/* =========================================================================
    CARD FLIP ANIMATION MECHANICS
   ========================================================================= */
.flip-container {
    perspective: 1000px;
    width: 100%;
    height: 80px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    text-align: center;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

.flip-card-inner.do-flip {
    transform: rotateY(180deg);
}

.flip-front, .flip-back {
    position: absolute;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    color: #FFFFFF;
}

.flip-front {
    background-color: #000000;
}

.flip-back {
    background-color: #101418;
    transform: rotateY(180deg);
}

/* =========================================================================
    PREVENT THE SCROLLBAR & OVERFLOW
   ========================================================================= */

/* Prevent the 1 to 10 game section from stretching the app container */
#game-1-to-10-screen {
    position: relative;
    max-height: 100%;
    overflow: hidden;
}

#number-guess-play-area {
    position: relative;
}

.number-guess-blurred-field {
    filter: blur(4px);
    opacity: 0.72;
    pointer-events: none;
    transform: scale(1.012);
    transition: filter 0.18s ease, opacity 0.18s ease, transform 0.18s ease;
}

#game-1-to-10-screen > div:not(.dashboard-header):not(.bottom-nav-bar):not(.number-guess-menu-area) {
    min-height: 0;
    padding: 14px 22px !important;
    gap: 12px !important;
    overflow: hidden;
}

#game-display-turn-prompt {
    flex: 0 0 51px;
    min-height: 51px;
    margin: 4px 0 0 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px !important;
    line-height: 1.15;
}

/* Force the number pad grid rows to scale flexibly instead of using fixed heights */
#game-1-to-10-screen > div {
    gap: 12px !important; /* Tighten up gaps to save vertical real estate */
}

/* Shrink the number pad buttons slightly so they fit without overflowing */
.pad-num-btn {
    padding: 8px 8px !important;
    font-size: 20px !important;
}

/* Tighten the submit action strip height */
#game-action-submit-strip {
    height: 52px !important;
    font-size: 20px !important;
}

.pad-num-btn.colour-tile {
    padding: 3px !important;
    font-size: 10px !important;
    line-height: 1.05;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.theme-peter .pad-num-btn.colour-tile.selected-key,
.theme-jadey .pad-num-btn.colour-tile.selected-key {
    color: #FFFFFF !important;
    box-shadow: inset 0 0 0 2px #FFFFFF;
}

.theme-peter .pad-num-btn.colour-tile.light-label.selected-key,
.theme-jadey .pad-num-btn.colour-tile.light-label.selected-key {
    color: #111111 !important;
    box-shadow: inset 0 0 0 2px #111111;
}

.turn-cue-overlay {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0;
    background: rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(4px);
    pointer-events: none;
    opacity: 0;
}

.battleship-content { position: relative; }
#battleship-shot-feedback { min-height: 20px; margin: 4px 0; font-size: 13px; text-align: center; color: #FFFFFF; }
.battleship-auto-setting { display: flex; align-items: center; gap: 12px; padding: 16px 0; }
.battleship-auto-setting input { width: 20px; height: 20px; accent-color: var(--theme-color); }
.battleship-cell.shot-impact { position: relative; z-index: 1; animation: battleship-impact 1.4s ease-out; }
.battleship-cell.shot-impact::after { content: ''; position: absolute; inset: -3px; border: 2px solid #A8E4F5; border-radius: 50%; animation: battleship-splash 1.4s ease-out forwards; pointer-events: none; }
.battleship-cell.hit.shot-impact::after { border-color: #FFC77D; }
@keyframes battleship-impact { 0%, 25% { box-shadow: 0 0 12px #A8E4F5; transform: scale(1.12); } 100% { box-shadow: none; transform: scale(1); } }
@keyframes battleship-splash { from { opacity: 1; transform: scale(.5); } to { opacity: 0; transform: scale(1.8); } }
@media (prefers-reduced-motion: reduce) { .battleship-cell.shot-impact { animation: none; outline: 2px solid #A8E4F5; } .battleship-cell.shot-impact::after { display: none; } }

.turn-cue-overlay.show-turn-cue {
    animation: turn-cue-panel 1s ease both;
}

.turn-cue-overlay span, .store-completion-text {
    position: relative;
    color: #FFFFFF;
    font-size: 34px;
    font-weight: 900;
    letter-spacing: 0;
    text-transform: uppercase;
}

.turn-cue-overlay span::after {
    content: "Your turn";
    position: absolute;
    inset: 0;
    color: transparent;
    background: linear-gradient(100deg, transparent 0%, transparent 35%, var(--turn-cue-colour, var(--theme-color)) 50%, transparent 65%, transparent 100%);
    background-size: 220% 100%;
    -webkit-background-clip: text;
    background-clip: text;
    animation: turn-cue-sweep 0.55s ease 0.12s both;
}

.word-search-complete-overlay {
    top: var(--pause-header-height, 58px);
    bottom: var(--pause-nav-height, 58px);
    padding: 16px;
    -webkit-backdrop-filter: blur(4px);
}
.word-search-complete-overlay span, .store-completion-text { font-size: 28px; text-align: center; }
.word-search-complete-overlay span::after { content: "Grid complete"; }
.sudoku-complete-overlay span::after { content: "Puzzle complete"; }
@media (prefers-reduced-motion: reduce) {
    .turn-cue-overlay.show-turn-cue { animation: none; opacity: 1; }
    .turn-cue-overlay span::after { animation: none; background: none; }
}

.round-summary-toast {
    position: absolute;
    left: 18px;
    right: 18px;
    top: 12px;
    z-index: 5;
    padding: 10px 12px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: rgba(10, 15, 20, 0.94);
    color: #FFFFFF;
    text-align: center;
    pointer-events: none;
    opacity: 0;
}

.round-summary-toast.show-round-summary {
    animation: round-summary-pop 1.75s ease both;
}

.round-summary-toast strong,
.round-summary-toast span {
    display: block;
}

.round-summary-toast strong {
    font-size: 15px;
}

.round-summary-toast span {
    margin-top: 2px;
    color: #8B949E;
    font-size: 12px;
}

.history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.number-guess-pause-stats {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.number-guess-pause-stats .stats-player-card {
    margin: 0;
}

.history-card {
    padding: 12px;
    border: 1px solid #161B22;
    border-radius: 8px;
    background: #0A0F14;
}

.history-card.correct {
    border-color: var(--theme-color);
}

.history-match-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 58px 14px 58px minmax(0, 1fr);
    align-items: center;
    gap: 6px;
}

.history-player-heading {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.history-player-heading span {
    color: #8B949E;
    font-size: 10px;
    font-weight: 800;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.history-player-heading strong {
    min-width: 0;
    overflow: hidden;
    color: #FFFFFF;
    font-size: 13px;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.history-player-heading.guesser {
    align-items: flex-end;
    text-align: right;
}

.history-divider {
    color: #8B949E;
    text-align: center;
    font-weight: 900;
}

.history-mini-card {
    width: 58px;
    min-height: 42px;
    padding: 4px;
    border: 2px solid #30363D;
    border-radius: 8px;
    background: #05080C;
    color: #FFFFFF;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    text-align: center;
    font-size: 15px;
    font-weight: 900;
    line-height: 1.05;
    overflow-wrap: anywhere;
}

.history-mini-card.peter { border-color: var(--peter-theme); }
.history-mini-card.jadey { border-color: var(--jadey-theme); }

.history-mini-card.colour {
    border-color: rgba(255, 255, 255, 0.4);
    font-size: 10px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.75);
}

.history-mini-card.light-label {
    color: #111111;
    text-shadow: none;
}

.history-score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 0;
    border-top: 1px solid #161B22;
    color: #C9D1D9;
    font-size: 13px;
}

.history-score-row strong {
    color: #FFFFFF;
}

.history-score-row.scored.peter strong {
    color: var(--peter-theme);
}

.history-score-row.scored.jadey strong {
    color: var(--jadey-theme);
}

.history-empty {
    padding: 18px 0;
    color: #8B949E;
    text-align: center;
    font-weight: 800;
}

@keyframes turn-cue-panel {
    0% { opacity: 0; }
    12% { opacity: 1; }
    78% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes turn-cue-sweep {
    from { background-position: 120% 0; }
    to { background-position: -120% 0; }
}

@keyframes round-summary-pop {
    0% { opacity: 0; transform: translateY(-8px); }
    14% { opacity: 1; transform: translateY(0); }
    82% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-5px); }
}
