/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* The hidden attribute must win over component display rules such as
   `display: flex`, otherwise toggled elements stay visible. */
[hidden] {
    display: none !important;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    line-height: 1.5;
    color: #e2e8f0;
    background: linear-gradient(135deg, #1a202c 0%, #2d3748 50%, #1a202c 100%);
    min-height: 100vh;
    margin: 0;
    padding: 0;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.header {
    background: rgba(26, 32, 44, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid #4a5568;
    padding: 0.75rem 0;
    position: relative;
    z-index: 100;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    color: inherit;
}

.logo-link:hover {
    opacity: 0.8;
}

.logo svg {
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.2);
}

.site-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #e2e8f0;
    margin: 0;
    white-space: nowrap;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.share-btn, .lang-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.share-btn:hover, .lang-btn:hover {
    background: #4a5568;
    border-color: #718096;
    transform: translateY(-1px);
}

.language-selector {
    position: relative;
}

.lang-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 450px;
    max-height: 300px;
    overflow-y: auto;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
}

.lang-dropdown.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-dropdown a {
    display: block;
    padding: 8px 16px;
    color: #e2e8f0;
    text-decoration: none;
    font-size: 0.875rem;
    transition: background-color 0.2s ease;
    white-space: nowrap;
}

.lang-dropdown a:hover {
    background: #4a5568;
}

.lang-column {
    display: flex;
    flex-direction: column;
}

/* Share Dropdown */
.header-actions {
    position: relative;
}

.share-dropdown {
    position: absolute;
    top: calc(100% + 8px);
    right: 0;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    min-width: 160px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
    z-index: 1000;
    display: flex;
    flex-direction: column;
}

.share-dropdown.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.share-option {
    background: none;
    border: none;
    color: #e2e8f0;
    padding: 12px 16px;
    text-align: left;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
}

/* `hidden` must win over the flex display above. */
.share-option[hidden] {
    display: none;
}

.share-option:hover {
    background: #4a5568;
}

.share-option:first-child {
    border-radius: 8px 8px 0 0;
}

.share-option:last-child {
    border-radius: 0 0 8px 8px;
}

/* ================================================================
   Accessibility helpers
   ================================================================ */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.skip-link {
    position: absolute;
    top: -60px;
    left: 12px;
    z-index: 10000;
    padding: 10px 16px;
    background: #3b82f6;
    color: #fff;
    font-weight: 600;
    border-radius: 0 0 8px 8px;
    text-decoration: none;
    transition: top 0.2s ease;
}

.skip-link:focus {
    top: 0;
}

/* Visible focus ring for keyboard users */
a:focus-visible,
button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible {
    outline: 2px solid #60a5fa;
    outline-offset: 2px;
}

/* ================================================================
   Share toast (replaces the blocking alert())
   ================================================================ */
.share-toast {
    position: fixed;
    left: 50%;
    bottom: 24px;
    transform: translate(-50%, 16px);
    z-index: 10001;
    padding: 10px 18px;
    border-radius: 10px;
    background: #1a202c;
    border: 1px solid #4a5568;
    color: #e2e8f0;
    font-size: 0.875rem;
    font-weight: 500;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
    max-width: calc(100vw - 32px);
    text-align: center;
}

.share-toast.show {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, 0);
}

/* Language dropdown active entry */
.lang-dropdown a.active {
    background: #2b6cb0;
    color: #fff;
    font-weight: 600;
}

/* ================================================================
   On-page navigation + quick answer block
   ================================================================ */
.onpage-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 2rem;
}

.onpage-nav a {
    display: inline-block;
    padding: 7px 14px;
    border-radius: 999px;
    background: #2d3748;
    border: 1px solid #4a5568;
    color: #cbd5e0;
    font-size: 0.85rem;
    font-weight: 500;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.onpage-nav a:hover {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #fff;
}

.quick-answer {
    margin: 1.25rem auto 0;
    max-width: 1000px;
    padding: 1rem 1.25rem;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-left: 4px solid #3b82f6;
    border-radius: 12px;
}

.quick-answer h2 {
    color: #e2e8f0;
    font-size: 1rem;
    font-weight: 700;
    margin: 0 0 0.6rem;
    letter-spacing: 0.01em;
}

.quick-answer ul {
    list-style: none;
    display: grid;
    gap: 0.5rem;
}

.quick-answer li {
    color: #a0aec0;
    font-size: 0.9rem;
    line-height: 1.6;
}

.quick-answer strong {
    color: #e2e8f0;
}

/* Main Content */
.main-content {
    padding: 1rem 0 0.5rem 0;
}

.game-container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Game Mode Selector */
.game-mode-selector {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}



.mode-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: #2d3748;
    border: 2px solid #4a5568;
    border-radius: 12px;
    color: #a0aec0;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    white-space: nowrap;
}

.mode-btn:hover {
    border-color: #3b82f6;
    color: #3b82f6;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.15);
}

.mode-btn.active {
    background: #3b82f6;
    border-color: #3b82f6;
    color: white;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.25);
}

/* Game Board Container */
.game-board-container {
    background: #2d3748;
    border-radius: 16px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    padding: 1.5rem;
    margin-bottom: 0.5rem;
    border: 1px solid #4a5568;
}

.game-mode {
    display: none;
}

.game-mode.active {
    display: block;
}

/* Online Game Layout Optimization */
.online-game {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-height: 100vh;
    overflow: hidden;
    background: #1a202c;
}

/* Game Info - Compact Toolbar
   ---------------------------------------------------------------------------
   Everything lives on a single row so the board gets as much height as
   possible:
     .game-info      -> one flex row, never wraps
     .player-info    -> compact stone chips (a 14px disc, one text line)
     .difficulty     -> bare select, no visible label
     .game-controls  -> icon + label, 32px tall
   -------------------------------------------------------------------------- */
.game-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 0;
    padding: 0.3rem 0.6rem;
    border-bottom: 1px solid #4a5568;
    flex-wrap: nowrap;
    gap: 0.5rem;
    flex-shrink: 0;
    background: #1a202c;
    z-index: 10;
}

/* Left group: player info + difficulty picker */
.game-info-top {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
    min-width: 0;
}

.player-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: nowrap;
}

/* Compact player chip - a stone disc plus a single line of text */
.player {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 3px 8px 3px 4px;
    background: #1a202c;
    border-radius: 999px;
    transition: background-color 0.3s ease, border-color 0.3s ease;
    border: 1px solid transparent;
}

.player.active {
    background: #2b6cb0;
    border-color: #3b82f6;
}

/* The stone itself communicates the colour - no icon needed */
.player-stone {
    width: 15px;
    height: 15px;
    border-radius: 50%;
    flex-shrink: 0;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.player-stone-black {
    background: radial-gradient(circle at 32% 28%, #4a5568, #1a202c 72%);
    border: 1px solid #64748b;
}

.player-stone-white {
    background: radial-gradient(circle at 32% 28%, #ffffff, #cbd5e0 78%);
    border: 1px solid #94a3b8;
}

.player-details {
    display: flex;
    align-items: baseline;
    gap: 5px;
    white-space: nowrap;
}

.player-name {
    font-weight: 600;
    color: #e2e8f0;
    font-size: 0.8rem;
    line-height: 1.2;
}

.vs-indicator {
    font-weight: 700;
    color: #718096;
    font-size: 0.7rem;
    letter-spacing: 0.04em;
}

.game-controls {
    display: flex;
    gap: 8px;
    flex-wrap: nowrap;
    align-items: center;
}

.control-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    /* 32px keeps the row slim; mobile overrides this to 44px+ */
    min-height: 32px;
    padding: 4px 10px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 7px;
    color: #e2e8f0;
    font-size: 0.75rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.control-btn svg {
    flex-shrink: 0;
}

.control-btn:hover:not(:disabled) {
    background: #2d3748;
    border-color: #718096;
}

.control-btn:active:not(:disabled) {
    transform: scale(0.96);
}

.control-btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* Difficulty picker - a bare select, no visible label.
   The <label> is still in the DOM (screen-reader only) so the control stays
   properly labelled for assistive technology. */
.difficulty-selector-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 0;
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 0.8rem;
    font-weight: 500;
    flex-shrink: 0;
}

.difficulty-selector-controls.active {
    display: flex;
}

.difficulty-selector-controls label {
    color: #a0aec0;
    white-space: nowrap;
}

.difficulty-selector-controls select {
    padding: 3px 6px;
    border: 1px solid #4a5568;
    border-radius: 6px;
    background: #2d3748;
    color: #e2e8f0;
    font-size: 0.72rem;
    cursor: pointer;
    min-width: 68px;
    /* Keep the native dropdown arrow but make it subtle */
    background-image: linear-gradient(45deg, transparent 50%, #a0aec0 50%),
                      linear-gradient(135deg, #a0aec0 50%, transparent 50%);
    background-position: calc(100% - 12px) 52%, calc(100% - 8px) 52%;
    background-size: 4px 4px, 4px 4px;
    background-repeat: no-repeat;
    appearance: none;
    -webkit-appearance: none;
    padding-right: 20px;
}

.primary-btn {
    background: #3b82f6 !important;
    color: white !important;
    border: 1px solid #3b82f6 !important;
}

.primary-btn:hover {
    background: #2563eb !important;
    border-color: #2563eb !important;
}

.secondary-btn {
    background: #6b7280 !important;
    color: white !important;
    border: 1px solid #6b7280 !important;
}

.secondary-btn:hover {
    background: #4b5563 !important;
    border-color: #4b5563 !important;
}

/* Board Wrapper - Default (AI Mode) */
.board-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    margin: 1rem 0 0.5rem 0;
    padding: 1rem;
    background: #1a202c;
    border-radius: 12px;
    border: 1px solid #4a5568;
    position: relative;
    text-align: center;
}

/* Board Wrapper - Online Game Optimized */
.online-game .board-wrapper {
    flex: 1;
    height: calc(100vh - 140px);
    max-height: calc(100vh - 140px);
    min-height: 400px; /* Ensure minimum height */
    margin: 0;
    padding: 0.5rem;
    background: #8B4513; /* Wood background color */
    border: 2px solid #654321;
    border-radius: 8px;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

#gameBoard, #onlineBoard {
    border: 2px solid #4a5568;
    border-radius: 8px;
    cursor: crosshair;
    background: #f7fafc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    display: block;
    margin: 0 auto;
}

/* Online Board - Maximized Display */
.online-game #onlineBoard {
    width: auto !important;
    height: auto !important;
    max-width: min(95vw, calc(100vh - 160px)) !important;
    max-height: min(calc(100vh - 160px), 95vw) !important;
    aspect-ratio: 1 / 1;
    border-radius: 4px;
}

/* Game Notifications */
.game-notifications {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(255, 255, 255, 0.95);
    color: #1a202c;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    border: 2px solid #3b82f6;
    font-size: 1.1rem;
    font-weight: 700;
    text-align: center;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
    max-width: 320px;
    width: max-content;
    word-wrap: break-word;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    /* The overlay sits on top of the board centre - it must never swallow
       clicks meant for the canvas. The action button opts back in. */
    pointer-events: none;
}

.notification-text {
    display: block;
}

/* The call to action inside a notification (for example "Play a friend
   online" after a win against the AI). */
.notification-action {
    pointer-events: auto;
    padding: 9px 18px;
    background: #2563eb;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.86rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease, transform 0.15s ease;
}

.notification-action:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}

.notification-action[hidden] {
    display: none;
}

.game-notifications.show {
    opacity: 1;
    visibility: visible;
}

.game-notifications.success {
    border-color: #10b981;
    background: rgba(220, 252, 231, 0.95);
    color: #064e3b;
}

.game-notifications.error {
    border-color: #ef4444;
    background: rgba(254, 226, 226, 0.95);
    color: #7f1d1d;
}

.game-notifications.warning {
    border-color: #f59e0b;
    background: rgba(255, 251, 235, 0.95);
    color: #78350f;
}

/* "AI is thinking" indicator (shown while the worker searches) */
.ai-thinking {
    position: absolute;
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 999px;
    background: rgba(26, 32, 44, 0.92);
    border: 1px solid #4a5568;
    color: #cbd5e0;
    font-size: 0.78rem;
    font-weight: 500;
    pointer-events: none;
    z-index: 5;
    backdrop-filter: blur(4px);
}

.ai-thinking[hidden] {
    display: none;
}

.ai-thinking-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #3b82f6;
    animation: aiPulse 1s ease-in-out infinite;
}

@keyframes aiPulse {
    0%, 100% { opacity: 0.35; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.15); }
}

/* Respect users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .ai-thinking-dot {
        animation: none;
        opacity: 0.9;
    }
}

/* Mode switch (AI / Online)
   ---------------------------------------------------------------------------
   A compact segmented control in the header. It stays out of the game
   toolbar so it never competes with the board for vertical space. */
.mode-switch {
    display: flex;
    align-items: center;
    gap: 2px;
    padding: 3px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 9px;
}

.mode-switch-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #a0aec0;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
    -webkit-tap-highlight-color: transparent;
}

.mode-switch-btn:hover {
    color: #e2e8f0;
    background: #2d3748;
}

.mode-switch-btn.active {
    background: #2b6cb0;
    color: #ffffff;
}

.mode-switch-btn svg {
    width: 15px;
    height: 15px;
}

/* Online status chip - replaces the difficulty picker in online mode */
.online-chip {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 5px 11px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.78rem;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.online-chip[hidden] {
    display: none;
}

.online-chip-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #3b82f6;
    animation: aiPulse 1.6s ease-in-out infinite;
    flex-shrink: 0;
}

/* Online room overlay
   ---------------------------------------------------------------------------
   Sits on top of the board while no opponent has joined, and again when the
   game ends. The board itself is never interactive while this is visible. */
.online-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(17, 24, 39, 0.86);
    backdrop-filter: blur(6px);
    z-index: 20;
}

.online-overlay[hidden] {
    display: none;
}

.online-card {
    width: 100%;
    max-width: 380px;
    background: #1a202c;
    border: 1px solid #4a5568;
    border-radius: 14px;
    padding: 22px 20px;
    text-align: center;
    box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
}

.online-title {
    margin: 0 0 6px;
    font-size: 1.12rem;
    font-weight: 600;
    color: #f7fafc;
    line-height: 1.3;
}

.online-desc {
    margin: 0 0 14px;
    font-size: 0.84rem;
    color: #a0aec0;
    line-height: 1.55;
}

.online-icon {
    width: 44px;
    height: 44px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2d3748;
    border: 1px solid #4a5568;
    color: #f7fafc;
    font-size: 1.25rem;
    font-weight: 700;
}

.online-icon[hidden] {
    display: none;
}

.online-spinner {
    width: 26px;
    height: 26px;
    margin: 0 auto 14px;
    border: 2px solid #4a5568;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: onlineSpin 0.8s linear infinite;
}

.online-spinner[hidden] {
    display: none;
}

@keyframes onlineSpin {
    to { transform: rotate(360deg); }
}

.online-link-box {
    display: flex;
    gap: 6px;
    margin-bottom: 14px;
}

.online-link-box[hidden] {
    display: none;
}

.online-link-input {
    flex: 1;
    min-width: 0;
    padding: 9px 11px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.78rem;
}

.online-link-input:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 1px;
}

.online-copy-btn {
    padding: 9px 14px;
    background: #2b6cb0;
    border: none;
    border-radius: 8px;
    color: #ffffff;
    font-size: 0.8rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    white-space: nowrap;
    transition: background-color 0.2s ease;
}

.online-copy-btn:hover {
    background: #3b82f6;
}

.online-countdown {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: #a0aec0;
}

.online-countdown[hidden] {
    display: none;
}

.online-countdown-time {
    font-family: var(--font-mono, ui-monospace, monospace);
    font-size: 0.95rem;
    font-weight: 700;
    color: #e2e8f0;
}

/* Queue position while looking for a random opponent */
.online-queue-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin: 0 0 14px;
    font-size: 0.82rem;
    color: #a0aec0;
}

.online-queue-info[hidden] {
    display: none;
}

.online-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}

.online-btn {
    padding: 9px 18px;
    background: #2d3748;
    border: 1px solid #4a5568;
    border-radius: 8px;
    color: #e2e8f0;
    font-size: 0.84rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.online-btn:hover {
    background: #4a5568;
}

.online-btn-primary {
    background: #2b6cb0;
    border-color: #3b82f6;
    color: #ffffff;
}

.online-btn-primary:hover {
    background: #3b82f6;
}

.online-btn[hidden] {
    display: none;
}

/* Fullscreen Mode
   ---------------------------------------------------------------------------
   The layout is a flex column:
     .fullscreen-mode      -> fixed overlay, exactly one viewport tall
       .game-mode.active   -> flex column, fills the overlay
         .game-info        -> natural height (the controls bar)
         .board-wrapper    -> flex:1, takes whatever height is left

   Because .board-wrapper is a flex item with a definite height, JavaScript can
   measure it and size the canvas to fit exactly - no guessing, no clipping.
   -------------------------------------------------------------------------- */
.fullscreen-mode {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    right: 0 !important;
    /* dvh tracks the mobile URL bar; vh is the fallback for older browsers. */
    height: 100vh !important;
    height: 100dvh !important;
    width: auto !important;
    max-width: none !important;
    max-height: none !important;
    background: #1a202c !important;
    z-index: 9999 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: flex-start !important;
    align-items: stretch !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    box-sizing: border-box !important;
    overflow: hidden !important;
}

/* Hide body scrollbar when in fullscreen */
body.fullscreen-active {
    overflow: hidden !important;
}

/* The active game mode becomes the flex column that holds the bar + board */
.fullscreen-mode .game-mode.active {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    width: 100% !important;
}

.fullscreen-mode .game-info {
    flex: 0 0 auto !important;
    width: 100% !important;
    max-width: 1400px !important;
    margin: 0.25rem auto !important;
    padding: 0.4rem 1rem !important;
    background: rgba(45, 55, 72, 0.8) !important;
    border-radius: 8px !important;
    display: flex !important;
    flex-wrap: nowrap !important;
    justify-content: space-between !important;
    align-items: center !important;
    gap: 0.5rem !important;
    position: relative !important;
    z-index: 2 !important;
}

/* Takes the remaining vertical space; JS measures it to size the canvas.
   flex-basis:0 removes any feedback loop between the canvas size and the
   space the wrapper is given. */
.fullscreen-mode .board-wrapper {
    flex: 1 1 0% !important;
    min-height: 0 !important;
    height: auto !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    align-items: center !important;
    width: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    background: transparent !important;
    border: none !important;
    overflow: hidden !important;
}

/* JS owns the exact pixel size; the caps are only a safety net */
.fullscreen-mode canvas {
    max-width: 100% !important;
    max-height: 100% !important;
    border-radius: 8px !important;
    aspect-ratio: 1 / 1 !important;
    display: block !important;
    margin: 0 auto !important;
    flex: 0 0 auto !important;
}

.fullscreen-mode .game-notifications {
    font-size: 1.2rem !important;
    padding: 1.5rem 2.5rem !important;
    max-width: 400px !important;
    border-width: 3px !important;
}

.fullscreen-mode .player-info {
    justify-content: center !important;
    align-items: center !important;
    gap: 1rem !important;
    flex-wrap: nowrap !important;
}

.fullscreen-mode .game-controls {
    justify-content: center !important;
    align-items: center !important;
    gap: 0.4rem !important;
    flex-wrap: nowrap !important;
}

.fullscreen-mode .control-btn {
    padding: 8px 12px !important;
    font-size: 0.8rem !important;
}

.fullscreen-mode .difficulty-selector-controls {
    padding: 6px 10px !important;
    font-size: 0.8rem !important;
}

.fullscreen-mode .difficulty-selector-controls select {
    padding: 4px 8px !important;
    font-size: 0.8rem !important;
}

/* Hide any potential scrollbars in fullscreen */
.fullscreen-mode * {
    scrollbar-width: none !important;
    -ms-overflow-style: none !important;
}

.fullscreen-mode *::-webkit-scrollbar {
    display: none !important;
}

/* Mobile / short-viewport fullscreen: shrink the controls bar so the board
   gets more room. Landscape phones are wide but short, so the height is the
   binding constraint there - hence the max-height query as well. */
@media (max-width: 768px), (max-height: 560px) {
    .fullscreen-mode .game-info {
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 0.35rem !important;
        padding: 0.35rem 0.5rem !important;
        margin: 0 !important;
        max-width: 100% !important;
        border-radius: 0 !important;
        background: rgba(26, 32, 44, 0.95) !important;
    }

    .fullscreen-mode .game-info-top {
        gap: 0.35rem !important;
    }

    .fullscreen-mode .player {
        padding: 2px 6px 2px 3px !important;
        gap: 4px !important;
    }

    .fullscreen-mode .player-stone {
        width: 12px !important;
        height: 12px !important;
    }

    .fullscreen-mode .player-name {
        font-size: 0.68rem !important;
    }

    .fullscreen-mode .vs-indicator {
        font-size: 0.65rem !important;
    }

    .fullscreen-mode .difficulty-selector-controls {
        padding: 0 !important;
        font-size: 0.68rem !important;
        gap: 4px !important;
    }

    .fullscreen-mode .difficulty-selector-controls select {
        padding: 2px 16px 2px 5px !important;
        font-size: 0.68rem !important;
        min-width: 62px !important;
    }

    .fullscreen-mode .game-controls {
        display: flex !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 4px !important;
    }

    .fullscreen-mode .control-btn {
        min-height: 34px !important;
        padding: 4px 8px !important;
        font-size: 0.6rem !important;
        gap: 3px !important;
        border-radius: 7px !important;
    }

    .fullscreen-mode .control-btn svg {
        width: 14px !important;
        height: 14px !important;
    }

    /* The board must never be pushed off the bottom */
    .fullscreen-mode .board-wrapper {
        justify-content: center !important;
        align-items: center !important;
        padding: 0 !important;
        margin: 0 !important;
    }
}



/* Difficulty Selector */
.difficulty-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    margin-top: 1rem;
}

.difficulty-selector label {
    font-weight: 500;
    color: #374151;
}

.difficulty-selector select {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
}

/* Online Lobby */
.online-lobby {
    display: flex;
    flex-direction: column;
    gap: 2rem;
}

/* Top Section with Create and Join Private */
.lobby-top-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
}

/* Public Rooms Section - Full Width */
.public-rooms-section {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.3);
}

.public-rooms-section h3,
.public-rooms-section .lobby-heading {
    color: white;
    margin-bottom: 1.5rem;
    font-size: 1.4rem;
    text-align: center;
}

.public-rooms-section .room-list {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    min-height: 200px;
}

.public-rooms-section .no-rooms {
    color: rgba(255, 255, 255, 0.9);
    text-align: center;
    padding: 3rem;
    font-style: italic;
    font-size: 1.1rem;
}

.public-rooms-section .room-list-footer {
    margin-top: 1rem;
    text-align: center;
}

.public-rooms-section .room-list-footer small {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
    font-size: 0.9rem;
}





.room-list-footer {
    margin-top: 0.5rem;
    text-align: center;
}

.room-list-footer small {
    color: rgba(255, 255, 255, 0.8);
    font-style: italic;
}

/* Disconnection Dialog */
.disconnection-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.dialog-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: dialogSlideIn 0.3s ease-out;
}

@keyframes dialogSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.dialog-content h3 {
    margin: 0 0 1rem 0;
    color: #e74c3c;
    font-size: 1.3rem;
}

.dialog-content p {
    margin: 0 0 1.5rem 0;
    color: #666;
    line-height: 1.5;
}

.dialog-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 1rem;
}

.wait-btn, .leave-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.wait-btn {
    background: #3498db;
    color: white;
}

.wait-btn:hover {
    background: #2980b9;
    transform: translateY(-1px);
}

.leave-btn {
    background: #e74c3c;
    color: white;
}

.leave-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.countdown {
    font-size: 0.8rem;
    color: #999;
    font-style: italic;
}

/* Rematch Dialog */
.rematch-dialog {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
}

.rematch-dialog .dialog-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 2rem;
    border-radius: 16px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    text-align: center;
    max-width: 400px;
    width: 90%;
    animation: dialogSlideIn 0.3s ease-out;
}

.rematch-dialog h3 {
    margin: 0 0 1rem 0;
    color: white;
    font-size: 1.3rem;
}

.rematch-dialog p {
    margin: 0 0 1rem 0;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.5;
}

.accept-btn, .decline-btn {
    flex: 1;
    padding: 0.75rem 1rem;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.accept-btn {
    background: #27ae60;
    color: white;
}

.accept-btn:hover {
    background: #229954;
    transform: translateY(-1px);
}

.decline-btn {
    background: #e74c3c;
    color: white;
}

.decline-btn:hover {
    background: #c0392b;
    transform: translateY(-1px);
}

.rematch-dialog .countdown {
    color: rgba(255, 255, 255, 0.8);
    margin-top: 1rem;
}

/* Mobile responsiveness for dialog */
@media (max-width: 768px) {
    .dialog-content {
        padding: 1.5rem;
        margin: 1rem;
    }

    .dialog-actions {
        flex-direction: column;
    }

    .wait-btn, .leave-btn {
        font-size: 0.85rem;
        padding: 0.6rem 0.8rem;
    }

    /* Mobile Online Game Optimization */
    .online-game {
        height: 100vh;
        max-height: 100vh;
    }

    .online-game .game-info {
        padding: 0.25rem 0.5rem;
        flex-wrap: wrap;
        gap: 0.25rem;
    }

    .online-game .board-wrapper {
        height: calc(100vh - 100px);
        max-height: calc(100vh - 100px);
        min-height: 300px;
        padding: 0.25rem;
        background: #8B4513; /* Ensure wood background on mobile */
        border: 1px solid #654321;
    }

    .online-game #onlineBoard {
        max-width: min(98vw, calc(100vh - 120px)) !important;
        max-height: min(calc(100vh - 120px), 98vw) !important;
    }

    .online-game .game-status {
        padding: 0.25rem 0.5rem;
        font-size: 0.85rem;
    }

    /* Mobile Online Lobby */
    .lobby-top-section {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .public-rooms-section {
        padding: 1rem;
    }

    .public-rooms-section h3,
    .public-rooms-section .lobby-heading {
        font-size: 1.2rem;
        margin-bottom: 1rem;
    }

    .public-rooms-section .room-list {
        padding: 1rem;
        min-height: 150px;
    }

    .public-rooms-section .no-rooms {
        padding: 2rem 1rem;
        font-size: 1rem;
    }
}

.lobby-section {
    background: #f8fafc;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
}

.lobby-section h3 {
    margin-bottom: 1rem;
    color: #1f2937;
    font-size: 1.1rem;
    font-weight: 600;
}

.lobby-heading {
    margin-bottom: 1rem;
    font-size: 1.1rem;
    font-weight: 600;
}

.room-creation {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.room-creation input {
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.room-options {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.875rem;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
}

.room-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 1rem;
}

.room-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-bottom: 8px;
}

.room-info {
    display: flex;
    flex-direction: column;
}

.room-name {
    font-weight: 500;
    color: #1f2937;
}

.room-players {
    font-size: 0.875rem;
    color: #6b7280;
}

.join-btn {
    padding: 6px 12px;
    background: #10b981;
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.join-btn:hover {
    background: #059669;
}

.join-private {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.join-private input {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    font-size: 0.875rem;
}

.game-status {
    text-align: center;
    margin: 0;
    padding: 0.5rem;
    background: #fef3c7;
    border-top: 1px solid #f59e0b;
    flex-shrink: 0;
}

/* Online Game Status - Compact Footer */
.online-game .game-status {
    margin: 0;
    padding: 0.5rem 1rem;
    background: #1a202c;
    border-top: 1px solid #4a5568;
    color: #e2e8f0;
    border-radius: 8px;
    color: #92400e;
    font-weight: 500;
}

/* Content Section */
.content-section {
    background: #2d3748;
    padding: 3rem 0;
    margin-top: 1rem;
}

.content-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    max-width: 1000px;
    margin: 0 auto;
    padding: 0 20px;
}

.content-block {
    background: #1a202c;
    padding: 2rem;
    border-radius: 16px;
    border: 1px solid #4a5568;
}

.content-block h2 {
    color: #e2e8f0;
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
    border-bottom: 3px solid #3b82f6;
    padding-bottom: 0.5rem;
}

.content-block h3 {
    color: #cbd5e0;
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.content-block p {
    color: #a0aec0;
    line-height: 1.7;
    margin-bottom: 1rem;
}

/* Rules List */
.rules-list {
    display: grid;
    gap: 1.5rem;
}

.rule-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Strategy Tips */
.strategy-tips {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
}

.tip-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border-top: 4px solid #10b981;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Features Grid */
.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
}

.feature-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.feature-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
}

.feature-item h3 {
    font-size: 1.1rem;
    margin-bottom: 0.75rem;
    color: #e2e8f0;
}

/* Comparison Table */
.comparison-table {
    overflow-x: auto;
    background: #2d3748;
    border-radius: 12px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.comparison-table table {
    width: 100%;
    border-collapse: collapse;
}

.comparison-table th,
.comparison-table td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #4a5568;
    color: #e2e8f0;
}

.comparison-table th {
    background: #1a202c;
    font-weight: 600;
    color: #cbd5e0;
}

.comparison-table tr:hover {
    background: #374151;
}

.comparison-table td strong {
    color: #3b82f6;
}

/* FAQ List */
.faq-list {
    display: grid;
    gap: 1rem;
}

.faq-item {
    background: #2d3748;
    padding: 1.5rem;
    border-radius: 12px;
    border: 1px solid #4a5568;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.faq-item h3 {
    color: #e2e8f0;
    margin-bottom: 0.75rem;
    font-size: 1.1rem;
}

/* Contact Form Styles */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: #2d3748;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease;
    box-sizing: border-box;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.submit-btn {
    background: #3b82f6;
    color: white;
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.submit-btn:hover {
    background: #2563eb;
}

/* Navigation Active State */
.nav a.active {
    color: #3b82f6;
    font-weight: 600;
}

/* Content Grid for Contact Page - specific class */
.contact-content-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 2rem;
    margin: 2rem 0;
}

/* Footer */
.footer {
    background: #1f2937;
    color: #d1d5db;
    padding: 3rem 0 1rem;
    margin-top: 4rem;
}

.footer-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.footer-section h3 {
    color: white;
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 1rem;
}

.footer-section p {
    line-height: 1.6;
    color: #9ca3af;
}

.footer-section ul {
    list-style: none;
}

.footer-section ul li {
    margin-bottom: 0.5rem;
}

.footer-section ul li a {
    color: #d1d5db;
    text-decoration: none;
    transition: color 0.2s ease;
}

.footer-section ul li a:hover {
    color: #3b82f6;
}

.footer-bottom {
    border-top: 1px solid #374151;
    padding-top: 1rem;
    text-align: center;
    color: #9ca3af;
    font-size: 0.875rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    .header-container {
        padding: 0 16px;
    }

    .header-actions {
        gap: 8px;
    }

    .share-btn, .lang-btn {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    /* The mode switch has to fit next to the share and language buttons,
       so on phones it collapses to the two icons. */
    .mode-switch {
        padding: 2px;
        border-radius: 8px;
    }

    .mode-switch-btn {
        padding: 6px 8px;
        gap: 0;
        font-size: 0.72rem;
    }

    .mode-switch-btn span {
        display: none;
    }

    .mode-switch-btn svg {
        width: 17px;
        height: 17px;
    }

    /* Keep the brand on one line - the header must not grow. */
    .site-title {
        font-size: 1.2rem;
    }

    .site-title-suffix {
        display: none;
    }

    .online-card {
        padding: 18px 16px;
    }

    .online-title {
        font-size: 1rem;
    }

    .online-desc {
        font-size: 0.8rem;
    }

    .online-link-input {
        font-size: 0.72rem;
        padding: 8px 9px;
    }

    .online-copy-btn {
        padding: 8px 12px;
        font-size: 0.76rem;
    }

    .game-mode-selector {
        flex-direction: row;
        gap: 8px;
        margin-bottom: 1rem;
        justify-content: center;
    }

    .mode-btn {
        flex: 1;
        max-width: 140px;
        justify-content: center;
        padding: 10px 12px;
        font-size: 0.8rem;
    }

    .difficulty-selector-controls {
        flex-direction: column;
        gap: 6px;
        padding: 10px;
        text-align: center;
    }

    .difficulty-selector-controls select {
        min-width: 120px;
    }

    /* ---- Mobile game area: board shell bleeds to the screen edges ---- */
    .main-content {
        padding: 0;
    }

    .game-container {
        max-width: 100%;
        padding: 0;
    }

    .game-board-container {
        padding: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
        box-shadow: none;
    }

    .board-wrapper {
        margin: 0;
        padding: 0;
        border-radius: 0;
        border: none;
        background: transparent;
    }

    /* The board is sized by JS; let it use the full width. */
    #gameBoard, #onlineBoard {
        width: 100%;
        max-width: 100%;
        height: auto;
        border-radius: 0;
        border: none;
        box-shadow: none;
        margin: 0 auto;
    }

    /* ---- Compact single-row toolbar ----
       Player chips, difficulty and the four actions all share one row so the
       board starts as high up the screen as possible. */
    .game-info {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        gap: 0.35rem;
        text-align: left;
        margin-bottom: 0;
        padding: 0.3rem 0.4rem;
        border-bottom: none;
        flex-wrap: nowrap;
    }

    .game-info-top {
        width: auto;
        justify-content: flex-start;
        gap: 0.35rem;
        flex-wrap: nowrap;
    }

    .player-info {
        justify-content: flex-start;
        gap: 0.3rem;
        flex-wrap: nowrap;
    }

    .player {
        padding: 2px 7px 2px 3px;
        gap: 5px;
    }

    .player-stone {
        width: 13px;
        height: 13px;
    }

    .player-name {
        font-size: 0.72rem;
    }

    .vs-indicator {
        font-size: 0.62rem;
    }

    .difficulty-selector-controls {
        flex-direction: row;
        align-items: center;
        gap: 0;
        margin-right: 0;
        padding: 0;
        text-align: left;
    }

    .difficulty-selector-controls select {
        min-width: 66px;
        padding: 4px 18px 4px 6px;
        font-size: 0.7rem;
    }

    /* Icon-only buttons: the labels stay in the DOM for screen readers.
       44x44 keeps the tap target comfortable without costing much width. */
    .game-controls {
        display: flex;
        flex-wrap: nowrap;
        gap: 4px;
        width: auto;
    }

    .control-btn {
        flex-direction: row;
        gap: 0;
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        font-size: 0.65rem;
        line-height: 1;
        text-align: center;
        white-space: nowrap;
        border-radius: 9px;
        justify-content: center;
    }

    /* The visible label is hidden on narrow screens, but the accessible
       name is preserved for screen readers. */
    .control-btn span {
        position: absolute;
        width: 1px;
        height: 1px;
        padding: 0;
        margin: -1px;
        overflow: hidden;
        clip: rect(0, 0, 0, 0);
        white-space: nowrap;
        border: 0;
    }

    .control-btn svg {
        width: 18px;
        height: 18px;
    }

    .online-lobby {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .lobby-section {
        padding: 1rem;
    }

    .content-section {
        padding: 2rem 0;
    }

    .content-grid {
        padding: 0 16px;
        gap: 2rem;
    }

    .content-block {
        padding: 1.5rem;
    }

    .features-grid {
        grid-template-columns: 1fr;
    }

    .strategy-tips {
        grid-template-columns: 1fr;
    }

    .footer-content {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .game-notifications {
        max-width: 250px;
        padding: 0.75rem 1.5rem;
        font-size: 1rem;
    }

    .quick-answer {
        margin: 1rem 0.75rem 0;
        padding: 0.85rem 1rem;
    }

    .onpage-nav {
        margin-bottom: 1.25rem;
        gap: 6px;
    }

    .onpage-nav a {
        padding: 6px 11px;
        font-size: 0.78rem;
    }
}

@media (max-width: 443px) {
    .main-content {
        padding: 0;
    }

    .game-container {
        padding: 0;
    }

    .game-mode-selector {
        margin-bottom: 0.5rem;
        gap: 6px;
    }

    .mode-btn {
        padding: 8px 10px;
        font-size: 0.75rem;
        max-width: 120px;
    }

    .game-board-container {
        padding: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
        margin-bottom: 0;
    }

    .game-info {
        margin-bottom: 0;
        gap: 0.25rem;
        padding: 0.25rem 0.3rem;
    }

    .board-wrapper {
        margin: 0;
        padding: 0;
        justify-content: flex-start !important;
        align-items: flex-start !important;
    }

    #gameBoard, #onlineBoard {
        max-width: 100%;
    }

    .content-section {
        padding: 1.5rem 0;
    }

    /* Fix content overflow on very small screens */
    .content-grid {
        padding: 0 12px !important;
        gap: 1rem !important;
    }

    .content-block {
        padding: 1rem 0.75rem !important;
        margin: 0 !important;
        border-radius: 8px !important;
        box-sizing: border-box !important;
        max-width: 100% !important;
        overflow: hidden !important;
    }

    .content-block h2 {
        font-size: 1.2rem !important;
        margin-bottom: 0.75rem !important;
    }

    .content-block p {
        font-size: 0.85rem !important;
        line-height: 1.4 !important;
    }

    .features-grid {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .feature-item {
        padding: 0.75rem !important;
        border-radius: 6px !important;
    }

    .strategy-tips {
        grid-template-columns: 1fr !important;
        gap: 0.75rem !important;
    }

    .tip-item {
        padding: 0.75rem !important;
        border-radius: 6px !important;
    }

    /* Small screen fullscreen mode - compact header */
    .fullscreen-mode {
        justify-content: flex-start !important;
        align-items: center !important;
        padding: 0 !important;
    }

    .fullscreen-mode .game-info {
        margin: 0.25rem auto !important;
        width: calc(100% - 0.5rem) !important;
        padding: 0.4rem 0.5rem !important;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 0.5rem 0;
    }

    .header-container {
        padding: 0 12px;
    }

    .site-title {
        font-size: 1.2rem;
    }

    .share-btn, .lang-btn {
        padding: 6px 10px;
        font-size: 0.75rem;
    }

    .main-content {
        padding: 0;
    }

    .game-container {
        padding: 0;
    }

    .game-board-container {
        padding: 0;
        border-radius: 0;
        border-left: none;
        border-right: none;
    }

    .mode-btn {
        max-width: 250px;
        padding: 10px 14px;
        font-size: 0.85rem;
    }

    /* Keep 44x44 tap targets even on the smallest screens - the icon-only
       row is narrow enough that this costs almost nothing. */
    .control-btn {
        min-width: 44px;
        min-height: 44px;
        padding: 0;
        font-size: 0.62rem;
        gap: 0;
    }

    .player {
        padding: 2px 6px 2px 3px;
        gap: 4px;
    }

    .player-stone {
        width: 12px;
        height: 12px;
    }

    .player-name {
        font-size: 0.7rem;
    }

    .content-block {
        padding: 1rem;
        border-radius: 12px;
    }

    .content-block h2 {
        font-size: 1.4rem;
    }

    #gameBoard, #onlineBoard {
        max-width: 100%;
    }

    .board-wrapper {
        padding: 0;
        margin: 0;
    }

    .game-notifications {
        max-width: 220px;
        padding: 0.5rem 1rem;
        font-size: 0.9rem;
    }

    .lobby-section {
        padding: 0.75rem;
    }

    .room-creation input,
    .join-private input {
        padding: 8px 10px;
        font-size: 0.8rem;
    }

    .lang-dropdown {
        min-width: 120px;
        max-height: 250px;
    }
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.game-mode {
    animation: fadeIn 0.3s ease-out;
}

/* Game Board Hover Effects */
#gameBoard:hover, #onlineBoard:hover {
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.15);
}

/* Button Loading State */
.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
