:root {
    --color-bg-page: #f2ebe0;
    --color-bg-modal: #faf7f2;
    --color-text: #2c2c2c;
    --color-muted: #6b5b4f;
    --color-border: #c4b59a;
    --color-border-btn: #a08b6e;
    --color-disabled-bg: #e8e4dc;
    --color-disabled-text: #888;
    --piece-white-fill: #ffffff;
    --piece-white-stroke: #2c2c2c;
    --piece-black-fill: #2c2c2c;
    --piece-black-stroke: #ffffff;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: rgba(0,0,0,0);
    outline: none !important;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
    background-color: var(--color-bg-page);
}

body {
    font-family: "Bookerly", "Caecilia", Georgia, serif;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

body.fullscreen-mode {
    padding: 0;
    margin: 0;
    background-color: #000;
}

body.fullscreen-mode .info,
body.fullscreen-mode .info-bottom {
    display: none;
}

body.fullscreen-mode .board-container {
    max-width: 100vh;
    max-height: 100vh;
    width: 100vw;
    height: 100vw;
    margin: 0;
}

body.fullscreen-mode .game-area,
body.fullscreen-mode .main-column {
    height: 100%;
    width: 100%;
}

body.fullscreen-mode .board {
    border: none;
}

.container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.game-area {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.main-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.info, .info-bottom {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin: 5px 0;
    height: 44px;
    width: calc(100vw - 10px);
    max-width: calc(100vh - 115px);
}

.info { transform: rotate(180deg); }

.info-center {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    flex: 1;
    min-width: 0;
    height: 44px;
    padding: 0 0 2px 0;
    text-align: center;
}

.btn {
    height: 44px;
    padding: 0;
    font-family: "Bookerly", "Caecilia", Georgia, serif;
    font-size: 24px;
    font-weight: bold;
    background: #2c2c2c;
    color: #fff;
    border: 1px solid #1a1a1a;
    border-radius: 0;
    width: calc(12.5% + 2px);
    flex: 0 0 calc(12.5% + 2px);
    line-height: 40px;
    cursor: pointer;
    touch-action: manipulation;
}

.btn:disabled { background: var(--color-disabled-bg); border-color: var(--color-border); color: var(--color-disabled-text); }
.btn.btn-new,
.btn-roll { font-size: 16px; width: auto; padding: 0 12px; flex: 0 0 auto; }

.btn-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-appearance: none;
    appearance: none;
    padding: 0;
}

.btn-nav svg {
    width: 26px;
    height: 22px;
    display: block;
    flex-shrink: 0;
    margin: 0 auto;
}

.btn-nav svg path { fill: #fff !important; }

.promotion-content .btn {
    width: 100%;
    flex: none;
    display: block;
    padding: 0 20px;
}

.status, .status-bottom {
    font-size: 14px;
    font-weight: bold;
    color: #2c2c2c;
    line-height: 1.2;
    margin-top: 2px;
    white-space: nowrap;
}

.score {
    font-size: 13px;
    font-weight: bold;
    line-height: 13px;
    height: 13px;
    margin: 0;
    display: block;
    color: #005500;
    transform: translateY(1px);
}

.captured-inline {
    display: flex;
    align-items: flex-end;
    padding: 0 0 2px 0;
    width: 70px;
    flex: 0 0 70px;
    height: 44px;
}
.captured-row {
    display: flex;
    align-items: flex-end;
    margin-right: 3px;
    height: 16px;
}
#capturedTopB, #capturedBottomW { justify-content: flex-start; margin-left: 8px; }
#capturedTopW, #capturedBottomB { justify-content: flex-end; margin-right: 8px; }
.captured-count {
    font-size: 13px;
    font-weight: bold;
    line-height: 13px;
    height: 13px;
    margin: 0;
    display: block;
    color: #6b5b4f;
}
.captured-symbol {
    width: 16px;
    height: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}
.captured-symbol svg { width: 100%; height: 100%; }

.board {
    position: relative;
    width: 100%;
    height: 100%;
    border: 2px solid #c4b59a;
    background: #b58863;
}
.square {
    position: absolute;
    width: 12.5%;
    height: 12.5%;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: manipulation;
}
.square.light { background-color: #F0E0C7; }
.square.dark { background-color: #b58863; }
.square.selected { background-color: #90a050 !important; border: 3px solid #2c2c2c !important; }
.square.last-move { background-color: #bac84a !important; border: 2px solid #2c2c2c !important; }
.square.possible-move::after {
    content: '';
    position: absolute;
    width: 30%;
    height: 30%;
    top: 35%;
    left: 35%;
    background-color: #5a5a5a;
    border-radius: 50%;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
.square.possible-capture::after {
    content: '';
    position: absolute;
    width: 90%;
    height: 90%;
    top: 5%;
    left: 5%;
    border: 3px solid #5a5a5a;
    border-radius: 50%;
    box-sizing: border-box;
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}
.square .coord-rank,
.square .coord-file {
    position: absolute;
    font-size: 10px;
    line-height: 1;
    pointer-events: none;
    user-select: none;
    z-index: 0;
}
.square .coord-rank { top: 2px; left: 2px; }
.square .coord-file { bottom: 2px; right: 2px; }
.square .coord-rank:empty,
.square .coord-file:empty { display: none; }
.square.light .coord-rank,
.square.light .coord-file { color: #2c2c2c; }
.square.dark .coord-rank,
.square.dark .coord-file { color: #f0e0c7; }
.square-inner {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    flex-shrink: 0;
}
.piece {
    position: relative;
    z-index: 1;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
}
.rank1 { top: 87.5%; } .rank2 { top: 75%; } .rank3 { top: 62.5%; } .rank4 { top: 50%; }
.rank5 { top: 37.5%; } .rank6 { top: 25%; } .rank7 { top: 12.5%; } .rank8 { top: 0%; }
.file1 { left: 0%; } .file2 { left: 12.5%; } .file3 { left: 25%; } .file4 { left: 37.5%; }
.file5 { left: 50%; } .file6 { left: 62.5%; } .file7 { left: 75%; } .file8 { left: 87.5%; }

.board-container {
    width: calc(100vw - 10px);
    height: calc(100vw - 10px);
    max-width: calc(100vh - 115px);
    max-height: calc(100vh - 115px);
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
}

.promotion-modal {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

#welcomeModal {
    background: var(--color-bg-page);
}

#welcomeModal .promotion-content {
    position: relative;
    background: var(--color-bg-modal);
    padding: 0;
    border: 1px solid var(--color-border);
    border-radius: 0;
    max-width: 400px;
    width: 90%;
    min-width: 340px;
    height: 580px;
    box-sizing: border-box;
    overflow: visible;
}

#welcomeModal .promotion-content-inner {
    overflow-y: auto;
    height: 100%;
    padding: 2.5em 2em 1em 2em;
    box-sizing: border-box;
    text-align: center;
}

.welcome-back-wrap {
    position: absolute;
    top: -0.47em;
    left: 0.5em;
}

#welcomeModal .welcome-back-link {
    display: block;
    width: 28px;
    height: 40px;
    text-decoration: none;
}

#welcomeModal .welcome-back-link svg {
    width: 100%;
    height: 100%;
    display: block;
}

#welcomeModal .welcome-back-link:hover svg path { fill: var(--color-text); }

#welcomeModal .promotion-title {
    font-size: 1.5em;
    font-weight: 600;
    letter-spacing: 0.02em;
    margin: 0.4em 0 1em;
    padding-bottom: 0.6em;
    border-bottom: 1px solid var(--color-border);
    color: var(--color-text);
}

#welcomeModal .btn {
    background: var(--color-bg-modal);
    border: 1px solid var(--color-border-btn);
    color: var(--color-text);
    padding-left: 30px;
    padding-right: 30px;
    width: 340px;
    box-sizing: border-box;
    font-size: 18px;
    font-weight: bold;
}

#welcomeModal .btn:disabled { background: var(--color-disabled-bg); border-color: var(--color-border); color: var(--color-disabled-text); }
#welcomeModal .welcome-continue-wrap { margin-bottom: 0.25em; }
#welcomeModal .welcome-buttons-wrap { display: flex; flex-direction: column; align-items: center; margin: 0 auto; }
#welcomeModal .welcome-buttons-wrap .title-page-actions,
#welcomeModal .welcome-buttons-wrap .welcome-continue-wrap { display: flex; flex-direction: column; align-items: stretch; }
#welcomeModal .title-page-actions { margin-top: 1em; }
#welcomeModal .chapter-label {
    font-size: 0.75em;
    letter-spacing: 0.15em;
    color: var(--color-muted);
    text-transform: uppercase;
    margin-bottom: 0.5em;
}

.welcome-variants-info-wrap {
    position: absolute;
    top: -0.47em;
    right: 0.5em;
}

.welcome-variants-info-btn {
    width: 28px;
    height: 40px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    display: block;
}

.welcome-variants-info-btn svg {
    width: 100%;
    height: 100%;
    display: block;
}

#gameInfoModal,
#variantsInfoModal {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: transparent;
    z-index: 1002;
    align-items: center;
    justify-content: center;
    padding: 1em;
}

#gameInfoModal.show,
#variantsInfoModal.show { display: flex; }

#gameInfoModal .variants-info-content,
#variantsInfoModal .variants-info-content {
    position: relative;
    background: var(--color-bg-page);
    border: 1px solid var(--color-border);
    max-width: 380px;
    width: calc(90vw - 20px);
    min-width: 320px;
    height: 560px;
    box-sizing: border-box;
    overflow-y: auto;
    padding: 1.25em 1.5em;
}

#gameInfoModal .variants-info-title,
#variantsInfoModal .variants-info-title {
    font-size: 1.5em;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 0.75em;
    padding-bottom: 0.5em;
    border-bottom: 1px solid var(--color-border);
}

#gameInfoModal .variant-item,
#variantsInfoModal .variant-item {
    margin-bottom: 0.85em;
    font-size: 0.9em;
    line-height: 1.35;
    color: var(--color-text);
}

#gameInfoModal .variant-item strong,
#variantsInfoModal .variant-item strong { color: var(--color-text); }

#gameInfoModal .variant-item span,
#variantsInfoModal .variant-item span { color: var(--color-muted); }

#gameInfoModal .variants-info-close,
#variantsInfoModal .variants-info-close {
    position: absolute;
    top: 0.5em;
    right: 0.5em;
    width: 32px;
    height: 32px;
    margin: 16px;
    padding: 0;
    border: none;
    background: transparent;
    color: var(--color-text);
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    justify-content: center;
}
#gameInfoModal .variants-info-close::before,
#variantsInfoModal .variants-info-close::before {
    content: '×';
    font-size: 2.5rem;
}

#eink-refresh-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background-color: #000;
    display: none;
    z-index: 10001;
}

.main-footer,
#welcomeFooter {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    text-align: center;
    padding: 10px;
    font-size: 12px;
    color: var(--color-muted);
}
#welcomeFooter { display: none; z-index: 1001; }

.main-footer a,
#welcomeFooter a {
    text-decoration: underline;
    color: var(--color-muted);
}
.main-footer a:hover,
#welcomeFooter a:hover { color: var(--color-text); }

.welcome-continue-wrap {
    margin-top: 14px;
}

@media (max-width: 600px) {
    .btn { font-size: 18px; line-height: 44px; }
}
