#feedback-modal {
    position: absolute;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(12, 6, 2, 0.72);
    z-index: 1020;
}

#feedback-modal-card {
    width: min(100%, 460px);
    display: grid;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #4a2b1d 0%, #2a150f 100%);
    border: 1px solid rgba(236, 189, 97, 0.34);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 233, 192, 0.12);
}

#feedback-modal-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 10px;
}

#feedback-modal-title {
    color: #f4dc9a;
    font-size: 1.22rem;
    line-height: 1.2;
}

#feedback-modal-description,
#feedback-modal-note {
    color: #f0dfc2;
    line-height: 1.5;
}

#feedback-modal-links {
    display: grid;
    gap: 10px;
}

#feedback-modal-links a {
    display: inline-flex;
    justify-content: center;
    align-items: center;
    min-height: 44px;
    padding: 10px 14px;
    border-radius: 12px;
    border: 1px solid rgba(236, 189, 97, 0.34);
    background: rgba(63, 35, 23, 0.96);
    color: #f6e8c8;
    text-decoration: none;
    font-weight: 800;
}

#feedback-modal-links a:hover,
#feedback-modal-links a:focus {
    background: rgba(85, 49, 31, 0.98);
    color: #fff4d2;
    outline: none;
}

#feedback-diagnostics-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

#feedback-diagnostics-actions button {
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(236, 189, 97, 0.34);
    background: rgba(63, 35, 23, 0.96);
    color: #f6e8c8;
    font-weight: 800;
    cursor: pointer;
}

#feedback-diagnostics-actions button:hover,
#feedback-diagnostics-actions button:focus {
    background: rgba(85, 49, 31, 0.98);
    color: #fff4d2;
    outline: none;
}

.feedback-diagnostics-message {
    min-height: 1.4em;
    color: #ffe9b9;
    font-size: 0.9rem;
    line-height: 1.45;
}

#feedback-modal-note {
    font-size: 0.88rem;
}

.secondary-start-button {
    background: rgba(69, 41, 26, 0.9);
    color: #f2dfba;
    border: 1px solid rgba(225, 186, 108, 0.4);
    flex: 1 1 150px;
    min-height: 44px;
    max-width: 210px;
    border-radius: 11px;
    padding: 8px 13px;
    font-size: 0.88rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.18);
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.secondary-start-button:hover,
.secondary-start-button:focus {
    background: rgba(86, 52, 34, 0.95);
    border-color: rgba(243, 211, 139, 0.62);
    color: #ffedc8;
    outline: none;
}

#how-to-play-modal {
    position: absolute;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(14, 7, 3, 0.76);
    z-index: 1010;
}

#player-stats-modal {
    position: absolute;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 16px;
    background: rgba(12, 6, 2, 0.76);
    z-index: 1010;
}

#player-stats-card {
    width: min(100%, 720px);
    max-height: min(90vh, 820px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #4a2b1d 0%, #28140f 100%);
    border: 1px solid rgba(236, 189, 97, 0.34);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 233, 192, 0.12);
}

#player-stats-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#player-stats-title {
    color: #f4dc9a;
    font-size: 1.28rem;
    line-height: 1.2;
}

#player-profile-content {
    min-height: 0;
    overflow-y: auto;
    display: grid;
    gap: 14px;
    padding-right: 4px;
    overscroll-behavior: contain;
}

#local-profile-card,
#player-achievements,
#player-statistics {
    display: grid;
    gap: 10px;
    padding: 12px;
    border-radius: 14px;
    border: 1px solid rgba(236, 189, 97, 0.24);
    background: rgba(25, 12, 8, 0.5);
}

#local-profile-card h4,
#player-achievements h4,
#player-statistics h4,
.stats-subtitle {
    margin: 0;
    color: #f4dc9a;
    font-size: 1rem;
    line-height: 1.25;
}

#profile-summary {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    gap: 12px;
}

#profile-preview-avatar {
    width: 68px;
    height: 68px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    border: 2px solid rgba(243, 203, 116, 0.65);
    background: radial-gradient(circle at 35% 25%, #75482d, #2a150e 72%);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.32);
    font-size: 2rem;
}

#profile-name-field {
    display: grid;
    gap: 6px;
}

#profile-name-field label,
#profile-avatar-picker legend {
    color: #f2d9a8;
    font-size: 0.84rem;
    font-weight: 700;
}

#profile-display-name {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border-radius: 10px;
    border: 1px solid rgba(236, 189, 97, 0.42);
    background: rgba(15, 8, 5, 0.78);
    color: #fff0cf;
    font: inherit;
}

#profile-preview-name {
    color: #fff0cf;
    font-size: 0.92rem;
}

#profile-local-note,
#profile-status {
    margin: 0;
    color: #e9d6b4;
    font-size: 0.8rem;
    line-height: 1.4;
}

#profile-avatar-picker {
    min-width: 0;
    margin: 0;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(236, 189, 97, 0.2);
}

#profile-avatar-grid {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    margin-top: 8px;
}

.profile-avatar-option {
    min-width: 0;
    min-height: 68px;
    display: grid;
    place-items: center;
    gap: 3px;
    padding: 7px 4px;
    border-radius: 11px;
    border: 1px solid rgba(236, 189, 97, 0.24);
    background: rgba(35, 17, 11, 0.82);
    color: #f1ddb9;
    cursor: pointer;
}

.profile-avatar-option > span {
    font-size: 1.48rem;
    line-height: 1;
}

.profile-avatar-option small {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.67rem;
}

.profile-avatar-option[data-selected="true"] {
    border-color: #f2c966;
    background: rgba(126, 76, 35, 0.9);
    box-shadow: 0 0 0 2px rgba(242, 201, 102, 0.2);
}

.profile-avatar-option:focus-visible,
#profile-display-name:focus-visible,
#profile-save-button:focus-visible,
#profile-reset-button:focus-visible {
    outline: 3px solid rgba(255, 221, 132, 0.82);
    outline-offset: 2px;
}

#profile-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#profile-actions button {
    min-height: 44px;
    border-radius: 10px;
    font-weight: 800;
    cursor: pointer;
}

#profile-save-button {
    border: 1px solid #e9c46a;
    background: #d8aa49;
    color: #201204;
}

#profile-reset-button {
    padding: 8px 12px;
}

#profile-status {
    min-height: 1.2em;
    color: #f5d991;
}

#achievement-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
}

.achievement-card {
    min-width: 0;
    display: grid;
    gap: 5px;
    align-content: start;
    padding: 10px;
    border-radius: 12px;
    border: 1px solid rgba(236, 189, 97, 0.18);
    background: rgba(20, 10, 7, 0.62);
    color: #d4c3a8;
    opacity: 0.62;
}

.achievement-card[data-unlocked="true"] {
    border-color: rgba(242, 201, 102, 0.62);
    background: linear-gradient(145deg, rgba(111, 67, 29, 0.88), rgba(39, 20, 12, 0.9));
    color: #fff0cf;
    opacity: 1;
}

.achievement-icon {
    font-size: 1.35rem;
}

.achievement-card strong {
    color: #f5dda4;
    font-size: 0.82rem;
}

.achievement-card > span:not(.achievement-icon) {
    font-size: 0.72rem;
    line-height: 1.3;
}

.achievement-state {
    color: #cdbb9c;
    font-size: 0.68rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.achievement-state[data-unlocked="true"] {
    color: #f6d56f;
}

#stats-empty-state {
    color: #f0dfc2;
    text-align: center;
    padding: 12px;
    border-radius: 12px;
    border: 1px dashed rgba(236, 189, 97, 0.35);
    background: rgba(24, 12, 8, 0.45);
}

#player-stats-cards {
    overflow-y: auto;
    display: grid;
    gap: 10px;
    padding-right: 2px;
}

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

.stats-row.stats-row-small {
    grid-template-columns: repeat(2, minmax(0, 1fr));
}

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

.stats-subtitle {
    margin-top: 4px;
    font-size: 0.88rem;
}

.stats-mini-card {
    border-radius: 12px;
    border: 1px solid rgba(236, 189, 97, 0.24);
    background: rgba(30, 14, 9, 0.56);
    padding: 10px;
    min-height: 74px;
    display: grid;
    gap: 6px;
    align-content: center;
}

.stats-label {
    color: #f4d9a5;
    font-size: 0.78rem;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

.stats-value {
    color: #fff0cf;
    font-size: 1.02rem;
    font-weight: 800;
    line-height: 1.2;
}

#player-stats-footer {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

#stats-close-footer-button {
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(236, 189, 97, 0.34);
    background: rgba(63, 35, 23, 0.96);
    color: #f0dbb2;
    font-weight: 700;
    cursor: pointer;
}

#how-to-play-card {
    width: min(100%, 640px);
    max-height: min(88vh, 740px);
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 12px;
    padding: 16px;
    border-radius: 18px;
    background: linear-gradient(180deg, #4a2b1d 0%, #2a150f 100%);
    border: 1px solid rgba(236, 189, 97, 0.34);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.58), inset 0 1px 0 rgba(255, 233, 192, 0.12);
}

#how-to-play-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

#how-to-play-title {
    color: #f4dc9a;
    font-size: 1.35rem;
    line-height: 1.2;
}

.guide-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid rgba(236, 189, 97, 0.35);
    background: rgba(45, 22, 15, 0.9);
    color: #ffe3ab;
    cursor: pointer;
    font-size: 1.15rem;
    font-weight: 800;
}

#how-to-play-pages {
    border-radius: 14px;
    border: 1px solid rgba(236, 189, 97, 0.22);
    background: rgba(22, 10, 7, 0.45);
    padding: 14px;
    overflow-y: auto;
}

.guide-page {
    display: none;
    color: #f1e0bf;
}

.guide-page.is-active {
    display: block;
}

.guide-page h4 {
    color: #f7dda1;
    font-size: 1.05rem;
    margin-bottom: 8px;
}

.guide-page p,
.guide-page li {
    font-size: 0.95rem;
    line-height: 1.45;
    color: #f0dfc2;
}

.guide-page ul {
    margin: 0;
    padding-left: 18px;
    display: grid;
    gap: 8px;
}

#how-to-play-footer {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
    align-items: center;
}

#guide-page-counter {
    text-align: center;
    color: #f5ddb0;
    font-weight: 700;
    font-size: 0.9rem;
    white-space: nowrap;
}

#guide-prev-button,
#guide-next-button,
#guide-start-button,
#guide-close-footer-button {
    min-height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(236, 189, 97, 0.34);
    font-weight: 700;
    cursor: pointer;
}

#guide-prev-button,
#guide-next-button {
    background: rgba(63, 35, 23, 0.96);
    color: #f0dbb2;
}

#guide-prev-button:disabled,
#guide-next-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

#guide-start-button {
    background: #d9ae52;
    color: #1c1001;
}

@media (max-width: 760px) {
    #how-to-play-card {
        max-height: min(90vh, 760px);
        padding: 14px;
    }

    #how-to-play-footer {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #guide-page-counter {
        grid-column: 1 / -1;
    }

    #player-stats-card {
        max-height: min(90vh, 760px);
        padding: 14px;
    }

    .stats-row,
    .stats-row.stats-row-small,
    .stats-row.stats-row-four {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #profile-avatar-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    #achievement-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 430px) {
    #player-stats-modal {
        padding: 8px;
    }

    #player-stats-card {
        max-height: 94vh;
        padding: 10px;
    }

    #profile-summary {
        grid-template-columns: 56px minmax(0, 1fr);
    }

    #profile-preview-avatar {
        width: 54px;
        height: 54px;
        font-size: 1.65rem;
    }

    #profile-actions,
    #player-stats-footer {
        grid-template-columns: 1fr;
    }
}

#game-over-box {
    background: linear-gradient(180deg, #2f1d10 0%, #150d08 100%);
    padding: 30px 45px;
    border-radius: 18px;
    text-align: center;
    box-shadow: 0 16px 32px rgba(0, 0, 0, 0.55);
    display: flex;
    flex-direction: column;
    gap: 18px;
    border: 1px solid rgba(255, 210, 110, 0.28);
}

#game-over-box h2 {
    font-size: 30px;
    color: #f2d17e;
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

#game-over-box p {
    color: #f6e7c9;
    line-height: 1.5;
}

#match-stats {
    background: rgba(255, 246, 205, 0.08);
    border: 1px solid rgba(255, 223, 146, 0.18);
    border-radius: 12px;
    padding: 14px 16px;
    color: #ffeecc;
}

#stats-details {
    margin-top: 10px;
    font-size: 1rem;
    font-weight: 700;
    color: #f9ecb5;
}
    /* Removed device-specific override to consolidate layout in main landscape rules */

#restart-button {
    background-color: #b18333;
    color: #fff8dd;
    border: 1px solid rgba(255, 230, 155, 0.45);
    padding: 12px 24px;
    font-size: 16px;
    font-weight: 700;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.2s;
    box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}

#restart-button:hover {
    background-color: #d4aa48;
    transform: translateY(-1px);
}

/* --- ORTA ÇITAYA GÖMÜLÜ MİNİMAL BUTONLAR --- */
#board-wrapper {
    position: relative;
    display: inline-block;
}

/* Responsive canvas sizing: keep logical canvas attributes, scale visually */
#board-wrapper {
    max-width: 100%;
    width: min(1000px, 90vw);
}

#game-canvas {
    width: 100%;
    height: auto;
    display: block;
}

/* Prevent overflow from absolute positioned action buttons on small screens */
#action-buttons {
    pointer-events: none;
}

/* Rotate notice (portrait on small devices) */
#rotate-notice {
    display: none;
    position: fixed;
    inset: auto 8px 16px 8px;
    left: auto;
    right: 8px;
    width: min(92vw, 320px);
    max-width: calc(100vw - 16px);
    background: rgba(0,0,0,0.8);
    color: #fff8dd;
    padding: 10px 14px;
    border-radius: 12px;
    font-weight: 700;
    z-index: 1100;
    gap: 8px;
    align-items: center;
    box-shadow: 0 6px 16px rgba(0,0,0,0.5);
    text-align: center;
    line-height: 1.3;
}

@media (max-width: 600px) and (orientation: portrait) {
    #rotate-notice {
        display: flex;
    }

    body.is-start-screen-open #rotate-notice {
        display: none;
    }
}

@media (orientation: landscape) {
    #rotate-notice {
        display: none !important;
    }
}

/* Media: landscape phones and small tablets — stack board then controls */
@media (max-width: 900px) and (orientation: landscape) {
    #game-container {
        flex-direction: column;
        align-items: center;
        gap: 10px;
        padding: 8px;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #board-wrapper {
        order: 0;
        width: 100%;
    }

    /* Info panel becomes a two-column compact grid on landscape mobile */
    #info-panel {
        order: 1;
        width: 100%;
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        align-items: center;
        padding: 8px 6px;
        box-sizing: border-box;
    }

    /* Give theme container full row so long labels wrap nicely */
    #theme-container {
        grid-column: 1 / -1;
        display: flex;
        align-items: center;
        gap: 8px;
        justify-content: flex-start;
        min-height: 44px;
        width: 100%;
        min-width: 0;
    }
    #theme-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }
    #panel-controls,
    #info-panel,
    #theme-container,
    #language-container,
    #difficulty-container {
        min-width: 0;
    }

    /* Timer and dice balance: timer shows title and value on separate lines */
    #timer-container {
        order: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 10px 8px;
        min-height: 64px;
    }

    /* using .timer-title element instead of pseudo-element */

    #timer-countdown {
        display: block;
        font-size: 1.05rem;
        font-weight: 800;
        line-height: 1;
    }

    /* Align dice next to timer and keep balanced spacing */
    #dice-container {
        justify-self: center;
        align-self: center;
        margin-left: 4px;
    }

    /* Ensure touch targets are comfortable */
    #bot-difficulty,
    #theme-select,
    #language-select {
        min-height: 44px;
        padding: 8px 10px;
        font-size: 14px;
    }

    /* Restart / action buttons larger for touch */
    #restart-button, #undo-button, #confirm-button {
        min-height: 44px;
        min-width: 44px;
        padding: 8px 12px;
        font-size: 15px;
    }

    /* Ensure controls have at least 6-8px between them */
    #info-panel > * { padding: 4px 0; }

    #action-buttons {
        left: 50%;
        bottom: -64px;
        transform: translateX(-50%);
        width: auto;
        pointer-events: auto;
    }
}

/* Media: portrait phones — gentle prompt to rotate, keep everything usable */
@media (max-width: 600px) and (orientation: portrait) {
    #rotate-notice {
        display: flex;
    }

    #game-container {
        padding: 6px;
    }

    #board-wrapper {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #action-buttons {
        left: 50%;
        bottom: -76px;
        transform: translateX(-50%);
        pointer-events: auto;
    }

    .die {
        width: 56px;
        height: 56px;
        min-width: 56px;
        font-size: 1.2rem;
    }

    #restart-button {
        padding: 12px 22px;
        font-size: 18px;
    }

    #undo-button, #confirm-button {
        width: 36px;
        height: 36px;
    }

    #game-over-box {
        width: 92%;
        padding: 18px;
    }
}

/* Small tweak to ensure overlays don't overflow on tiny screens */
#game-over-overlay {
    padding: 12px;
}

#action-buttons {
    position: absolute;
    left: auto;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    width: auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    align-items: center;
    pointer-events: none;
}

#action-buttons button {
    pointer-events: auto;
    width: 24px;
    height: 24px;
    border-radius: 50%; 
    border: none;
    background-color: rgba(0, 0, 0, 0.4); 
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px; 
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.8), 0 1px 1px rgba(255,255,255,0.1); 
    transition: all 0.2s ease;
}

#undo-button:disabled,
#confirm-button:disabled {
    cursor: default;
}

#action-buttons button:active {
    transform: translateY(2px) scale(0.95); 
}

#undo-button:hover {
    background-color: rgba(231, 76, 60, 0.9);
    color: white;
}

#confirm-button:hover {
    background-color: rgba(46, 204, 113, 0.9);
    color: white;
}/* --- ZORLUK SEÇİCİ STİLİ --- */
#difficulty-container {
    display: flex;
    align-items: center;
    background-color: #2c3e50;
    padding: 4px 8px;
    border-radius: 6px;
}

#bot-difficulty {
    background-color: #34495e;
    color: white;
    border: 1px solid #4e6d8c;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

#bot-difficulty:hover {
    border-color: #e67e22;
}

/* --- İSTATİSTİK KARTI STİLİ --- */
#match-stats {
    background-color: rgba(0, 0, 0, 0.2);
    padding: 10px;
    border-radius: 6px;
    font-size: 14px;
    color: #bdc3c7;
    margin: 5px 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

#match-stats p {
    font-weight: bold;
    color: #f39c12;
}/* --- AĞA TAHTASI VE LÜKS KAPSÜL BUTONLAR --- */
body {
    background: linear-gradient(135deg, #1a252f 0%, #0d1117 100%); /* Daha derin, lüks bir gece tonu arka plan */
}

#game-container {
    background: #1e1b18; /* Tahtanın arkasında lüks bir ahşap gövde hissi */
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 15px 35px rgba(0, 0, 0, 0.7), inset 0 2px 5px rgba(255, 255, 255, 0.1);
    border: 2px solid #4a3525;
}

#info-panel {
    background: linear-gradient(to bottom, #3d2f24, #2c2119);
    border: 1px solid #5c4331;
    box-shadow: 0 4px 10px rgba(0,0,0,0.5);
}

/* --- ORTA ÇITAYA GÖMÜLÜ KAPSÜL BUTONLAR (Yandex Tarzı) --- */
#board-wrapper {
    position: relative;
    display: inline-block;
    border: 4px solid #3d2f24;
    border-radius: 6px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.6);
}

#action-buttons {
    position: absolute;
    /* Tahtanın tam ortasındaki ahşap çıtanın üzerine milimetrik yerleşim */
    left: 352px; 
    bottom: 75px; 
    width: 40px; 
    display: flex;
    flex-direction: column; 
    gap: 15px;
    align-items: center;
    pointer-events: none; 
}

#action-buttons button {
    pointer-events: auto;
    width: 65px; /* Yatay kapsül formu */
    height: 28px;
    border-radius: 14px; /* Oval kapsül kenarlar */
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    font-size: 11px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 4px;
    padding: 0 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.5), inset 0 1px 2px rgba(255,255,255,0.3);
    transition: all 0.2s ease;
    text-shadow: 0 1px 2px rgba(0,0,0,0.8);
}

#action-buttons button:active {
    transform: translateY(2px) scale(0.96); 
}

/* İptal / Geri Al Kapsülü (Tok Kırmızı-Kahve Tonu) */
#undo-button {
    background: linear-gradient(to bottom, #c0392b, #962d22);
}

#undo-button:hover {
    background: linear-gradient(to bottom, #e74c3c, #c0392b);
    box-shadow: 0 0 10px rgba(231, 76, 60, 0.6);
}

/* Hamleyi Bitir Kapsülü (Tok Sedef Yeşil Tonu) */
#confirm-button {
    background: linear-gradient(to bottom, #27ae60, #1e8449);
}

#confirm-button:disabled,
#confirm-button[aria-disabled='true'] {
    background: linear-gradient(to bottom, #4f5b52, #3d463f);
    border-color: rgba(211, 224, 203, 0.2);
    color: rgba(231, 239, 226, 0.58);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.08);
    text-shadow: none;
}

#confirm-button:hover {
    background: linear-gradient(to bottom, #2ecc71, #27ae60);
    box-shadow: 0 0 10px rgba(46, 204, 113, 0.6);
}

#confirm-button:disabled:hover,
#confirm-button[aria-disabled='true']:hover {
    background: linear-gradient(to bottom, #4f5b52, #3d463f);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35), inset 0 1px 1px rgba(255, 255, 255, 0.08);
}

/* Kullanılmış zarın artık oynanamayacağını açıkça gösterir. */
.die {
    transition: opacity 160ms ease, filter 160ms ease, transform 160ms ease;
}

.die.used {
    opacity: 0.28;
    filter: grayscale(1);
    transform: scale(0.92);
}


/* Dil seçimi bot seviyesiyle aynı görsel dili kullanır. */
#language-container,
#theme-container {
    display: flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}

#language-container label,
#theme-container label,
#difficulty-container label {
    font-size: 13px;
}

#language-select,
#theme-select {
    background: #294966;
    color: #ffffff;
    border: 1px solid #66829c;
    border-radius: 6px;
    padding: 7px 9px;
    cursor: pointer;
}


/* Canvas iç çözünürlüğü yüksek DPI için büyür; ekrandaki ölçüsü sabit kalır. */
#game-canvas {
    display: block;
    width: min(800px, calc(100vw - 32px));
    height: auto;
}

#board-wrapper {
    max-width: 100%;
}


/* --- GÖRSEL UYUM VE OKUNAKLILIK PAKETİ --- */


body {
    overflow: auto;
    padding: 18px;
}

#game-container {
    width: min(846px, calc(100vw - 24px));
}

#info-panel {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
    padding: 12px 14px 10px;
    background: linear-gradient(180deg, #3c2916 0%, #24180d 100%);
    border: 1px solid rgba(219, 169, 80, 0.25);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06), 0 14px 28px rgba(0, 0, 0, 0.32);
    border-radius: 16px;
}

#panel-controls {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    width: 100%;
    align-items: stretch;
}

#turn-indicator,
#timer-container,
#dice-container,
#difficulty-container,
#language-container,
#theme-container {
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 12px 14px;
    border-radius: 14px;
    background: rgba(255, 224, 141, 0.08);
    border: 1px solid rgba(215, 171, 97, 0.25);
    color: #f7e6c3;
}

#turn-indicator {
    background: linear-gradient(180deg, #463524 0%, #2d1f15 100%);
    border-color: rgba(240, 200, 120, 0.28);
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
    font-size: 1rem;
    font-weight: 700;
    color: #f9e6c3;
    text-align: center;
}

#timer-container {
    min-height: 58px;
    padding-top: 18px;
    background: linear-gradient(180deg, #2c1b11 0%, #4a3220 100%);
    border-color: rgba(229, 177, 96, 0.32);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.05);
    color: #ffebc5;
    flex-direction: column;
    position: relative;
}

/* timer title is provided by .timer-title element in HTML */

#difficulty-container,
#language-container,
#theme-container,
#fullscreen-container {
    justify-content: space-between;
    gap: 10px;
    background: rgba(255, 236, 176, 0.08);
}

#difficulty-container label,
#language-container label,
#theme-container label {
    font-size: 0.88rem;
    color: #f5e7c0;
    white-space: nowrap;
}

#fullscreen-container {
    padding: 8px;
}

#fullscreen-toggle {
    width: 100%;
    min-height: 42px;
    border-radius: 12px;
    border: 1px solid rgba(222, 177, 95, 0.46);
    background: linear-gradient(180deg, rgba(86, 35, 34, 0.95) 0%, rgba(57, 21, 20, 0.96) 100%);
    color: #f8e8c8;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 10px;
    cursor: pointer;
    font-weight: 700;
    line-height: 1.1;
    box-shadow: inset 0 1px 0 rgba(255, 224, 198, 0.2), 0 6px 12px rgba(0, 0, 0, 0.28);
}

#fullscreen-toggle:hover,
#fullscreen-toggle:focus-visible {
    border-color: rgba(248, 208, 121, 0.7);
    background: linear-gradient(180deg, rgba(107, 47, 45, 0.95) 0%, rgba(70, 29, 28, 0.96) 100%);
    outline: none;
}

#fullscreen-toggle.is-active {
    background: linear-gradient(180deg, rgba(66, 84, 34, 0.96) 0%, rgba(42, 52, 24, 0.97) 100%);
    border-color: rgba(223, 203, 132, 0.68);
}

.fullscreen-toggle-icon {
    width: 16px;
    height: 16px;
    flex: 0 0 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.fullscreen-toggle-icon svg {
    width: 16px;
    height: 16px;
    display: block;
    stroke: currentColor;
    stroke-width: 1.6;
    stroke-linecap: round;
    stroke-linejoin: round;
    fill: none;
}

.fullscreen-toggle-label {
    font-size: 0.78rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

#bot-difficulty,
#language-select,
#theme-select {
    flex: 1;
    width: 100%;
    min-width: 0;
    background: rgba(29, 16, 8, 0.82);
    color: #f7e5c7;
    border: 1px solid rgba(215, 171, 97, 0.4);
    border-radius: 12px;
    padding: 10px 12px;
    font-size: 0.92rem;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

#bot-difficulty:hover,
#language-select:hover,
#theme-select:hover {
    border-color: rgba(255, 216, 126, 0.55);
}

#theme-select {
    max-width: 150px;
}

#status-message {
    width: 100%;
    min-height: 30px;
    display: flex;
    align-items: center;
    padding: 6px 10px;
    border-top: 1px solid rgba(220, 184, 116, 0.18);
    background: rgba(15, 9, 5, 0.22);
    border-radius: 5px;
    color: #e0d3c2;
    line-height: 1.25;
}

#board-wrapper {
    width: 100%;
    background: linear-gradient(to bottom, #2b1c13, #17100b);
    overflow: hidden;
}

#game-canvas {
    width: 100%;
}

#action-buttons {
    inset: 0;
    width: 100%;
    height: 100%;
    padding: 0 18%;
    transform: none;
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
    z-index: 4;
    opacity: 0;
    visibility: hidden;
    transition:
        opacity 180ms ease,
        visibility 0s linear 180ms;
}

#action-buttons.is-visible {
    opacity: 1;
    visibility: visible;
    transition-delay: 0s;
}

#action-buttons button {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    font-size: 22px;
    border: 1px solid rgba(255, 224, 172, 0.42);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

#action-buttons button:active {
    transform: translateY(1px) scale(0.97);
}

@media (max-width: 760px) {
    body {
        align-items: flex-start;
        padding: 8px;
    }

    #game-container {
        width: calc(100vw - 16px);
        padding: 6px;
        gap: 10px;
    }

    #panel-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    #turn-indicator,
    #timer-container,
    #dice-container {
        justify-self: stretch;
    }

    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container {
        justify-content: space-between;
    }

    #bot-difficulty,
    #language-select,
    #theme-select {
        min-width: 0;
        max-width: 120px;
    }

    #action-buttons {
        padding: 0 15%;
    }

    #action-buttons button {
        width: 48px;
        height: 48px;
        font-size: 23px;
    }
}


/* Fare, dokunmatik ekran ve kalem için ortak tahta etkileşimi. */
#game-canvas {
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    cursor: pointer;
}

/* Masaüstünde oyun tahtasını ekran yüksekliğine sığdırır. */
@media (min-width: 761px) {
    #game-container {
        width: min(
            846px,
            calc(100vw - 24px),
            calc(133.333vh - 333px)
        );
    }
}

/* Masaüstü: tahta solda, oyun bilgileri dikey olarak sağda. */
@media (min-width: 901px) {
    body {
        align-items: center;
    }

    #game-container {
        display: grid;
        grid-template-columns: minmax(0, 800px) 220px;
        grid-template-areas: "board info";
        align-items: stretch;
        gap: 12px;
        width: min(1058px, calc(100vw - 24px));
    }

    #board-wrapper {
        grid-area: board;
        align-self: center;
    }

    #info-panel {
        grid-area: info;
        width: 220px;
        min-width: 0;
        height: 100%;
        align-content: start;
        padding: 14px 12px;
    }

    #panel-controls {
        grid-template-columns: minmax(0, 1fr);
        align-content: start;
        gap: 10px;
    }

    #turn-indicator,
    #timer-container,
    #dice-container,
    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container {
        width: 100%;
    }

    #turn-indicator,
    #timer-container {
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 42px;
        text-align: center;
    }

    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container {
        justify-content: space-between;
    }

    #bot-difficulty,
    #language-select,
    #theme-select {
        min-width: 0;
        max-width: 132px;
    }

    #dice-container,
    #dice-display {
        justify-content: center;
    }

    #status-message {
        align-items: flex-start;
        min-height: 76px;
        margin-top: 2px;
        text-align: center;
    }
}

/* Tablet ve telefon: önce tahta, sonra katlanan bilgi paneli. */
@media (max-width: 900px) {
    #game-container {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas:
            "board"
            "info";
    }

    #board-wrapper {
        grid-area: board;
    }

    #info-panel {
        grid-area: info;
    }
}

/* Sağ paneli sade tutmak için durum mesajı görselden kaldırıldı. */
#status-message {
    display: none;
}

/* --- MOBİL VE DOKUNMATİK KONTROL PANELİ --- */
button,
select {
    touch-action: manipulation;
}

@media (max-width: 600px) and (orientation: portrait) {
    body {
        width: 100%;
        min-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        padding:
            max(4px, env(safe-area-inset-top))
            max(4px, env(safe-area-inset-right))
            max(6px, env(safe-area-inset-bottom))
            max(4px, env(safe-area-inset-left));
        overflow: hidden;
    }
    #board-wrapper {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    #game-container {
        min-width: 0;
        width: 100%;
    }
    #panel-controls,
    #info-panel,
    #theme-container,
    #language-container,
    #difficulty-container {
        min-width: 0;
    }

    #game-container {
        width: 100%;
        max-height: 100%;
        padding: 4px;
        gap: 6px;
        border-width: 1px;
        border-radius: 7px;
    }

    #board-wrapper {
        border-width: 2px;
        border-radius: 4px;
    }

    #info-panel {
        padding: 7px;
        border-radius: 7px;
    }

    #panel-controls {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        grid-template-areas:
            "turn timer dice"
            "bot language theme";
        gap: 6px;
    }

    #turn-indicator {
        grid-area: turn;
    }

    #timer-container {
        grid-area: timer;
    }

    #dice-container {
        grid-area: dice;
    }

    #difficulty-container {
        grid-area: bot;
    }

    #language-container {
        grid-area: language;
    }

    #theme-container {
        grid-area: theme;
        display: flex;
        width: 100%;
        justify-content: space-between;
        align-items: center;
        gap: 6px;
    }

    #theme-container #theme-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #turn-indicator,
    #timer-container,
    #dice-container {
        min-height: 40px;
        justify-content: center;
        align-items: center;
        text-align: center;
        font-size: 12px;
    }

    #difficulty-container,
    #language-container,
    #theme-container {
        min-width: 0;
        min-height: 44px;
        padding: 3px;
        justify-content: center;
        gap: 3px;
    }

    #difficulty-container label,
    #language-container label,
    #theme-container label {
        flex: 0 0 auto;
        font-size: 12px;
    }

    #bot-difficulty,
    #language-select,
    #theme-select {
        width: 100%;
        min-width: 0;
        max-width: none;
        min-height: 40px;
        padding: 4px 3px;
        font-size: 12px;
    }

    #theme-container label {
        display: none;
    }

    #dice-display {
        gap: 5px;
    }

    .die {
        width: 34px;
        height: 34px;
        font-size: 16px;
    }

    #action-buttons {
        padding: 0 11%;
    }

    #action-buttons button {
        width: 52px;
        height: 52px;
        font-size: 25px;
    }
}

/* Tüm mobil/tablet dikey ekranlarda oyun tek sahneye sığar. */
@media (max-width: 900px) and (orientation: portrait) {
    body {
        width: 100%;
        height: 100dvh;
        min-height: 100dvh;
        overflow: hidden;
        overscroll-behavior: none;
    }

    #game-container {
        grid-template-rows: minmax(0, 1fr) auto;
        width: 100%;
        max-height: 100%;
    }

    #board-wrapper {
        width: 100%;
        max-height: calc(100vh - 170px);
        max-height: calc(100dvh - 170px);
        justify-self: center;
        align-self: center;
    }

    #game-canvas {
        width: 100%;
        max-height: calc(100vh - 170px);
        max-height: calc(100dvh - 170px);
        object-fit: contain;
    }

    #info-panel {
        max-height: none;
        overflow: visible;
    }
}

/* Alçak ve yatay telefonlarda tahta solda, panel sağda kalır. */
@media (max-height: 600px) and (orientation: landscape) {
    body {
        width: 100%;
        min-width: 100%;
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        align-items: center;
        padding:
            max(4px, env(safe-area-inset-top))
            max(4px, env(safe-area-inset-right))
            max(4px, env(safe-area-inset-bottom))
            max(4px, env(safe-area-inset-left));
        overflow: hidden;
        overscroll-behavior: none;
    }
    #board-wrapper {
        min-width: 0;
        max-width: 100%;
        width: 100%;
    }
    #game-container {
        min-width: 0;
        width: 100%;
    }
    #panel-controls,
    #info-panel,
    #theme-container,
    #language-container,
    #difficulty-container {
        min-width: 0;
    }

    #game-container {
        display: grid;
        grid-template-columns:
            minmax(0, calc(133.333dvh - 24px))
            minmax(170px, 190px);
        grid-template-areas: "board info";
        width: min(
            100%,
            calc(133.333dvh + 172px)
        );
        height: min(100%, calc(100dvh - 8px));
        padding: 4px;
        gap: 6px;
    }

    #board-wrapper {
        grid-area: board;
        align-self: center;
        border-width: 2px;
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 18px);
        max-height: calc(100dvh - 18px);
        min-width: 0;
    }

    #game-canvas {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 18px);
        max-height: calc(100dvh - 18px);
        object-fit: contain;
    }

    #info-panel {
        grid-area: info;
        width: 100%;
        height: 100%;
        padding: 6px;
        align-content: center;
        overflow: hidden;
    }

    #panel-controls {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 5px;
    }

    #turn-indicator,
    #timer-container,
    #dice-container {
        min-height: 38px;
        justify-content: center;
        text-align: center;
        font-size: 12px;
    }

    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container {
        min-height: 42px;
        padding: 3px;
        justify-content: space-between;
        width: 100%;
        min-width: 0;
    }

    #bot-difficulty,
    #language-select,
    #theme-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
        min-height: 38px;
        padding: 3px 4px;
        font-size: 12px;
    }

    #theme-container label {
        display: none;
    }

    #action-buttons {
        padding: 0 12%;
    }

    #action-buttons button {
        width: 48px;
        height: 48px;
    }
}

@media (width: 430px) and (height: 932px) and (orientation: portrait) {
    #rotate-notice {
        display: flex;
    }
    html, body, #game-container, #board-wrapper, #info-panel, #panel-controls {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    #board-wrapper {
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }
    #game-canvas {
        width: 100%;
        max-width: 100%;
        max-height: calc(100vh - 160px);
        max-height: calc(100dvh - 160px);
    }
    #theme-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}

@media (width: 932px) and (height: 430px) and (orientation: landscape) {
    #rotate-notice {
        display: none !important;
    }
    html, body, #game-container, #board-wrapper, #info-panel, #panel-controls {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }
    #theme-select {
        width: 100%;
        min-width: 0;
        max-width: 100%;
    }
}

@media (max-width: 600px) and (orientation: portrait) {
    html, body {
        width: 100%;
        min-width: 0;
        min-height: 100vh;
        min-height: 100dvh;
        height: 100vh;
        height: 100dvh;
        overflow-x: hidden;
        overflow-y: auto;
        padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
    }

    body {
        display: block;
    }

    #game-container,
    #board-wrapper,
    #info-panel,
    #panel-controls {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #board-wrapper,
    #game-canvas {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        max-height: calc(100vh - 170px);
        max-height: calc(100dvh - 170px);
    }

    #info-panel {
        max-height: none;
        overflow: visible;
    }

    #rotate-notice {
        display: flex;
        position: fixed;
        inset: auto 50% 14px auto;
        transform: translateX(50%);
        width: min(88vw, 320px);
        max-width: calc(100vw - 16px);
        white-space: normal;
    }

    #theme-select,
    #language-select,
    #bot-difficulty {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    #action-buttons {
        right: 12px;
        left: auto;
        width: auto;
        pointer-events: none;
    }

    #start-screen-box {
        padding: 18px 14px 16px;
    }

    #start-screen-description {
        margin-bottom: 12px;
        font-size: 0.9rem;
    }

    #start-language-container {
        width: 100%;
        max-width: 100%;
        margin-bottom: 14px;
        padding: 6px 8px;
        gap: 6px;
    }

    #start-language-label {
        font-size: 0.82rem;
        gap: 5px;
    }

    #start-language-select {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        min-height: 44px;
        font-size: 0.84rem;
        padding: 6px;
    }

    #start-mode-grid {
        gap: 8px;
    }

    .start-mode-card {
        min-height: 86px;
    }

    .start-mode-card-unavailable {
        min-height: 72px;
    }

    button.start-mode-card {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 7px;
        padding: 10px 8px;
    }

    .start-mode-card-action {
        grid-template-columns: 30px minmax(0, 1fr);
        gap: 7px;
        padding: 9px 8px 5px;
    }

    .start-mode-icon {
        width: 29px;
        height: 29px;
    }

    .start-mode-icon svg {
        width: 22px;
        height: 22px;
    }

    .start-mode-copy strong {
        font-size: 0.88rem;
    }

    .start-mode-copy > span:not(.start-mode-badge) {
        font-size: 0.69rem;
    }

    .start-mode-config {
        gap: 5px;
        padding: 0 7px 7px;
    }

    #start-bot-difficulty,
    #start-turn-timer {
        min-width: 0;
        width: 100%;
        min-height: 44px;
        font-size: 0.72rem;
    }

    #feedback-button-row {
        margin-top: 8px;
    }

    #feedback-modal-card {
        width: min(100%, 420px);
        padding: 14px;
    }

    #feedback-modal-title {
        font-size: 1.08rem;
    }

    #feedback-modal-links a {
        min-height: 42px;
        padding: 9px 12px;
    }

    #feedback-diagnostics-actions {
        grid-template-columns: 1fr;
    }

    #feedback-diagnostics-actions button {
        min-height: 42px;
        padding: 9px 12px;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    html, body,
    #game-container,
    #board-wrapper,
    #info-panel,
    #panel-controls {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    body {
        overflow: hidden;
    }

    #board-wrapper,
    #game-canvas {
        width: 100%;
        max-width: 100%;
        min-width: 0;
        max-height: calc(100vh - 120px);
        max-height: calc(100dvh - 120px);
    }

    #rotate-notice {
        display: none !important;
    }

    #theme-select,
    #language-select,
    #bot-difficulty {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    #action-buttons {
        right: 12px;
        left: auto;
        width: auto;
    }

    #start-screen {
        padding: 6px;
    }

    #start-screen-box {
        width: min(100%, 720px);
        max-height: calc(100dvh - 12px);
        padding: 12px 14px;
    }

    #start-screen-box h2 {
        margin-bottom: 5px;
        font-size: 1.28rem;
    }

    #start-screen-description {
        margin-bottom: 7px;
        font-size: 0.78rem;
        line-height: 1.25;
    }

    #start-language-container {
        margin-bottom: 7px;
        padding: 4px 7px;
    }

    #start-language-select {
        min-height: 44px;
        padding: 4px 6px;
        font-size: 0.76rem;
    }

    #start-mode-menu {
        gap: 5px;
        margin-bottom: 7px;
    }

    #start-mode-menu-title {
        font-size: 0.66rem;
    }

    #start-mode-grid {
        gap: 6px;
    }

    .start-mode-card {
        min-height: 72px;
        border-radius: 12px;
    }

    .start-mode-card-unavailable {
        min-height: 64px;
    }

    button.start-mode-card,
    .start-mode-card-action {
        grid-template-columns: 28px minmax(0, 1fr);
        gap: 7px;
        padding: 7px 8px;
    }

    .start-mode-card-action {
        padding-bottom: 3px;
    }

    .start-mode-icon {
        width: 27px;
        height: 27px;
        border-radius: 8px;
    }

    .start-mode-icon svg {
        width: 20px;
        height: 20px;
    }

    .start-mode-copy strong {
        font-size: 0.82rem;
    }

    .start-mode-copy > span:not(.start-mode-badge) {
        font-size: 0.65rem;
        line-height: 1.15;
    }

    .start-mode-badge {
        padding: 2px 6px;
        font-size: 0.56rem;
    }

    .start-mode-config {
        gap: 5px;
        padding: 0 7px 6px;
    }

    .start-mode-config label {
        font-size: 0.64rem;
    }

    #start-bot-difficulty,
    #start-turn-timer {
        min-height: 44px;
        padding: 3px 6px;
        font-size: 0.68rem;
    }

    #start-screen-actions {
        gap: 6px;
    }

    .secondary-start-button,
    .feedback-start-button {
        min-height: 44px;
        padding: 7px 10px;
        font-size: 0.76rem;
    }

    #feedback-button-row {
        margin-top: 6px;
    }
}

@media (width: 430px) and (height: 932px) and (orientation: portrait) {
    #rotate-notice {
        display: flex;
    }
}

@media (width: 932px) and (height: 430px) and (orientation: landscape) {
    #rotate-notice {
        display: none !important;
    }
}

/* Compact and accessible turn strip: single-row status line with subtle color glow only. */
#info-panel > #turn-indicator {
    width: 100%;
    min-height: 34px;
    padding: 7px 10px;
    border-radius: 999px;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 8px;
    line-height: 1;
    font-size: 0.9rem;
    font-weight: 700;
    white-space: nowrap;
    border: 1px solid rgba(255, 228, 160, 0.22);
    transition:
        background-color 180ms ease,
        color 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease;
}

#turn-indicator .turn-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex: 0 0 10px;
    transition: background-color 180ms ease, box-shadow 180ms ease;
}

#turn-indicator .turn-prefix {
    flex: 0 0 auto;
    opacity: 0.93;
}

#turn-indicator #current-player {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

#info-panel > #turn-indicator.is-white-turn {
    background: linear-gradient(180deg, rgba(245, 219, 152, 0.93) 0%, rgba(219, 177, 93, 0.91) 100%);
    color: #2f1a07;
    box-shadow: inset 0 1px 0 rgba(255, 251, 230, 0.45), 0 0 12px rgba(255, 210, 112, 0.2);
}

#info-panel > #turn-indicator.is-white-turn .turn-dot {
    background: #fff7d7;
    box-shadow: 0 0 8px rgba(255, 225, 145, 0.82);
}

#info-panel > #turn-indicator.is-dark-turn {
    background: linear-gradient(180deg, rgba(66, 28, 34, 0.95) 0%, rgba(40, 15, 21, 0.96) 100%);
    color: #f6e4d9;
    box-shadow: inset 0 1px 0 rgba(255, 206, 190, 0.12), 0 0 10px rgba(126, 36, 47, 0.24);
}

#info-panel > #turn-indicator.is-dark-turn .turn-dot {
    background: #d7a58f;
    box-shadow: 0 0 6px rgba(196, 104, 90, 0.55);
}

@media (max-width: 760px) {
    #info-panel > #turn-indicator {
        min-height: 32px;
        padding: 6px 9px;
        font-size: 0.85rem;
    }
}

@media (max-height: 600px) and (orientation: landscape) {
    #info-panel > #turn-indicator {
        min-height: 30px;
        padding: 5px 8px;
        font-size: 0.82rem;
    }
}

body.is-game-fullscreen {
    overflow: hidden;
    overscroll-behavior: none;
}

body.is-game-fullscreen #rotate-notice {
    display: none !important;
}

#game-container:fullscreen,
#game-container:-webkit-full-screen,
#game-container.is-focus-mode-root {
    --fs-safe-top: env(safe-area-inset-top, 0px);
    --fs-safe-right: env(safe-area-inset-right, 0px);
    --fs-safe-bottom: env(safe-area-inset-bottom, 0px);
    --fs-safe-left: env(safe-area-inset-left, 0px);
    padding:
        max(8px, var(--fs-safe-top))
        max(8px, var(--fs-safe-right))
        max(8px, var(--fs-safe-bottom))
        max(8px, var(--fs-safe-left));
    margin: 0;
    background: #1a252f;
    overflow: hidden;
    align-content: center;
    justify-items: center;
}

#game-container:fullscreen,
#game-container:-webkit-full-screen,
#game-container.is-focus-mode-root,
#game-container.is-fullscreen-root-active {
    width: min(calc(100vw - 16px), calc((100dvh - 16px) * 1.7));
    max-width: none;
    max-height: calc(100dvh - 16px);
    gap: clamp(8px, 1.2vw, 14px);
}

#game-container.is-focus-mode-root {
    position: fixed;
    inset: 0;
    z-index: 1200;
}

#game-container.is-fullscreen-root-active #board-wrapper,
#game-container:fullscreen #board-wrapper,
#game-container:-webkit-full-screen #board-wrapper,
#game-container.is-focus-mode-root #board-wrapper {
    width: 100%;
    max-width: 100%;
    max-height: 100%;
}

#game-container.is-fullscreen-root-active #game-canvas,
#game-container:fullscreen #game-canvas,
#game-container:-webkit-full-screen #game-canvas,
#game-container.is-focus-mode-root #game-canvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: calc(100dvh - 24px);
    object-fit: contain;
}

@media (min-width: 901px) {
    #game-container.is-fullscreen-root-active,
    #game-container:fullscreen,
    #game-container:-webkit-full-screen,
    #game-container.is-focus-mode-root {
        grid-template-columns: minmax(0, 1fr) minmax(0, 0.275fr);
        grid-template-areas: "board info";
        align-items: stretch;
    }

    #game-container.is-fullscreen-root-active #info-panel,
    #game-container:fullscreen #info-panel,
    #game-container:-webkit-full-screen #info-panel,
    #game-container.is-focus-mode-root #info-panel {
        width: 100%;
        height: 100%;
    }
}

@media (max-width: 900px) {
    #game-container.is-fullscreen-root-active,
    #game-container:fullscreen,
    #game-container:-webkit-full-screen,
    #game-container.is-focus-mode-root {
        width: min(calc(100vw - 16px), calc((100dvh - 16px) * 1.333333));
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr) auto;
        grid-template-areas:
            "board"
            "info";
    }

    #game-container.is-fullscreen-root-active #board-wrapper,
    #game-container:fullscreen #board-wrapper,
    #game-container:-webkit-full-screen #board-wrapper,
    #game-container.is-focus-mode-root #board-wrapper {
        max-height: calc(100dvh - 190px);
    }

    #game-container.is-fullscreen-root-active #game-canvas,
    #game-container:fullscreen #game-canvas,
    #game-container:-webkit-full-screen #game-canvas,
    #game-container.is-focus-mode-root #game-canvas {
        max-height: calc(100dvh - 190px);
    }
}

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

/* Desktop layout stability: keep page height and panel card sizes fixed across turn/controls state changes. */
@media (min-width: 901px) {
    body {
        min-height: 100dvh;
        height: 100dvh;
        padding-top: max(10px, env(safe-area-inset-top));
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    #game-container {
        max-height: calc(
            100dvh -
            max(10px, env(safe-area-inset-top)) -
            max(10px, env(safe-area-inset-bottom))
        );
        align-items: stretch;
    }

    #info-panel {
        padding: 12px 10px;
        gap: 8px;
        overflow: visible;
    }

    #panel-controls {
        gap: 8px;
    }

    #turn-indicator,
    #timer-container,
    #dice-container,
    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container,
    #auto-bearoff-container {
        min-height: 42px;
        padding: 8px 10px;
        border-width: 1px;
    }

    #info-panel > #turn-indicator,
    #info-panel > #turn-indicator.is-white-turn,
    #info-panel > #turn-indicator.is-dark-turn {
        min-height: 34px;
        height: 34px;
        padding: 7px 10px;
        border-width: 1px;
        border-style: solid;
    }

    #fullscreen-container {
        min-height: 52px;
    }

}

/* Short desktop screens: compact panel rhythm without clipping content. */
@media (min-width: 901px) and (max-height: 900px) {
    #start-screen-box {
        padding-block: 17px 14px;
    }

    #start-screen-description {
        margin-bottom: 10px;
    }

    #start-language-container {
        margin-bottom: 8px;
    }

    #start-mode-menu {
        margin-bottom: 8px;
    }

    .start-mode-card {
        min-height: 78px;
    }

    .start-mode-card-unavailable {
        min-height: 70px;
    }

    #info-panel {
        padding: 10px 8px;
        gap: 6px;
    }

    #panel-controls {
        gap: 6px;
    }

    #turn-indicator,
    #timer-container,
    #dice-container,
    #difficulty-container,
    #language-container,
    #theme-container,
    #fullscreen-container,
    #auto-bearoff-container {
        min-height: 40px;
        padding: 7px 9px;
    }

}
/* Distribution adapters reserve these without changing the default web layout. */
:root {
    --platform-ad-safe-top: 0px;
    --platform-ad-safe-right: 0px;
    --platform-ad-safe-bottom: 0px;
    --platform-ad-safe-left: 0px;
}

body[data-platform='yandex'] #game-container {
    padding-top: max(env(safe-area-inset-top), var(--platform-ad-safe-top));
    padding-right: max(env(safe-area-inset-right), var(--platform-ad-safe-right));
    padding-bottom: max(env(safe-area-inset-bottom), var(--platform-ad-safe-bottom));
    padding-left: max(env(safe-area-inset-left), var(--platform-ad-safe-left));
}

body[data-platform-input-blocked] #game-container {
    pointer-events: none;
    user-select: none;
}
