:root {
    --game-primary: #c90c0f;
    --game-secondary: #fab719;
    --tg-ink: #2a1810;
    --tg-wood: #6b3f22;
}

body.tg-page {
    margin: 0;
    min-height: 100vh;
    font-family: "Rockwell", "Rockwell Nova", "Roboto Slab", serif;
    color: #f8f4ea;
    background:
        radial-gradient(circle at 14% 10%, rgba(250, 183, 25, 0.18), transparent 42%),
        radial-gradient(circle at 88% 8%, rgba(201, 12, 15, 0.22), transparent 46%),
        linear-gradient(180deg, #2a1810 0%, #4a2c18 46%, #1a120c 100%);
}

body.tg-page.game-menu-active {
    overflow-y: auto;
    overflow-x: hidden;
}

body.tg-page.game-menu-active #game-header {
    display: none !important;
}

.tg-page .game-screen {
    display: none;
    min-height: 100vh;
}

.tg-page .game-screen.active {
    display: block;
}

body.tg-page.with-game-header .tg-shell {
    padding-top: 5.5rem;
}

.tg-shell {
    max-width: min(1100px, 96vw);
    margin: 0 auto;
    padding: 1.1rem 0.75rem 2.5rem;
}

.tg-hud {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    margin: 0 auto 0.85rem;
    padding: 0.55rem 0.7rem;
    background: linear-gradient(180deg, #5a351c, #3b2414);
    border: 3px solid #1a120c;
    border-radius: 12px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12), 0 10px 24px rgba(0, 0, 0, 0.35);
}

.tg-lcd {
    min-width: 6.2rem;
    padding: 0.2rem 0.45rem;
    background: #140414;
    color: #f5c518;
    font-family: "Courier New", ui-monospace, monospace;
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-align: center;
    border-radius: 6px;
    box-shadow: inset 0 0 0 2px #7f1d1d, inset 0 8px 16px rgba(0, 0, 0, 0.45);
}

.tg-lcd span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #fde68a;
}

.tg-chip {
    padding: 0.45rem 0.7rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #fde68a;
    font-weight: 700;
}

.tg-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.45rem;
    margin: 0 auto 0.85rem;
}

.tg-tool-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.5rem 0.75rem;
    border-radius: 999px;
    border: 2px solid rgba(250, 183, 25, 0.45);
    background: #fff8e7;
    color: #3b2414 !important;
    font-weight: 700;
    cursor: pointer;
}

.tg-tool-btn:hover,
.tg-tool-btn:focus-visible {
    background: #c90c0f;
    border-color: #c90c0f;
    color: #fff !important;
}

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

.tg-tool-btn.is-on {
    background: #c90c0f;
    border-color: #c90c0f;
    color: #fff !important;
}

.tg-board-wrap {
    background:
        radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.08), transparent 40%),
        linear-gradient(160deg, #8b5a2b 0%, #5c3a1e 55%, #3b2414 100%);
    border: 4px solid #1a120c;
    border-radius: 16px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 16px 32px rgba(0, 0, 0, 0.4);
    overflow: hidden;
    touch-action: none;
}

.tg-board {
    display: block;
    width: 100%;
    height: auto;
    min-height: 52vh;
    cursor: default;
}

.tg-silhouette,
.tg-silhouette polygon {
    fill: #000;
    stroke: #000;
    fill-opacity: 1;
    stroke-linejoin: round;
    stroke-linecap: round;
}

.tg-silhouette-guide {
    fill: #000;
    fill-opacity: 0.16;
    stroke: none;
}

.tg-piece {
    cursor: grab;
    stroke: rgba(26, 18, 12, 0.55);
    stroke-width: 0.08;
    filter: drop-shadow(0.08px 0.12px 0.08px rgba(0, 0, 0, 0.35));
}

.tg-piece:active,
.tg-piece.is-dragging {
    cursor: grabbing;
}

.tg-piece.is-selected {
    stroke: #fab719;
    stroke-width: 0.18;
    filter: drop-shadow(0 0 0.18px #fab719);
}

.tg-piece.is-snapped {
    stroke: #86efac;
    stroke-width: 0.16;
}

.tg-hint {
    text-align: center;
    color: #fde68a;
    margin: 0.7rem 0 0;
    font-size: 0.95rem;
}

.tg-picker-group {
    margin-bottom: 1.1rem;
}

.tg-picker-group h3 {
    margin: 0 0 0.55rem;
    color: #7f1d1d;
    font-size: 1.05rem;
}

.tg-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: 0.75rem;
}

.tg-picker-card {
    background: #fff8e7;
    color: #3b2414 !important;
    border: 2px solid #c90c0f;
    border-radius: 12px;
    padding: 0.55rem;
    cursor: pointer;
    text-align: center;
}

.tg-picker-card:hover,
.tg-picker-card:focus-visible {
    background: #c90c0f;
    color: #fff !important;
}

.tg-picker-card svg {
    width: 100%;
    height: 88px;
    display: block;
    margin-bottom: 0.35rem;
    background: #f4e4c1;
    border-radius: 8px;
}

.tg-picker-card strong {
    display: block;
    font-size: 0.95rem;
}

.tg-picker-card span {
    font-size: 0.75rem;
    opacity: 0.8;
    text-transform: capitalize;
}

.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.72);
    z-index: 12000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: #fff;
    color: #1a1a1a;
    border-radius: 1rem;
    max-width: 640px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-large {
    max-width: 920px;
}

.modal-header,
.modal-footer {
    padding: 1.1rem 1.4rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.modal-header {
    border-bottom: 2px solid #eee;
}

.modal-header h2 {
    margin: 0;
    color: #c90c0f;
    font-size: 1.35rem;
}

.modal-close {
    background: #fff;
    border: 2px solid #c90c0f;
    color: #c90c0f;
    border-radius: 8px;
    cursor: pointer;
    padding: 0.35rem 0.55rem;
}

.modal-close:hover,
.modal-close:focus-visible {
    background: #c90c0f;
    color: #fff;
}

.modal-body {
    padding: 1.2rem 1.4rem;
}

.modal-footer {
    border-top: 2px solid #eee;
    justify-content: flex-end;
}

.help-section {
    margin-bottom: 1.1rem;
}

.help-section h3 {
    color: #c90c0f;
    margin: 0 0 0.4rem;
}

.help-section ul {
    margin: 0.3rem 0 0;
    padding-left: 1.2rem;
}

.help-tans {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    margin-top: 0.5rem;
}

.help-tan {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.55rem;
    border-radius: 999px;
    background: #fff8e7;
    color: #3b2414;
    font-size: 0.85rem;
    font-weight: 700;
}

.help-tan i {
    width: 0.7rem;
    height: 0.7rem;
    border-radius: 2px;
    display: inline-block;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.stat-card {
    background: #f8fafc;
    border-radius: 12px;
    padding: 0.85rem;
    text-align: center;
}

.stat-value {
    font-size: 1.6rem;
    color: #c90c0f;
    font-weight: 700;
}

.stat-label {
    color: #64748b;
    font-size: 0.85rem;
}

.difficulty-stats {
    display: grid;
    gap: 0.45rem;
}

.difficulty-stats div {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0.55rem;
    background: #f8fafc;
    border-radius: 8px;
}

.result-message {
    font-size: 1.05rem;
    margin: 0 0 1rem;
}

.win-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.6rem;
    text-align: center;
}

.win-stat strong {
    display: block;
    font-size: 1.35rem;
    color: #c90c0f;
}

.win-stat span {
    color: #64748b;
    font-size: 0.82rem;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.65rem 1.1rem;
    border-radius: 0.55rem;
    border: 2px solid transparent;
    font-weight: 700;
    cursor: pointer;
}

.btn-primary {
    background: #c90c0f;
    color: #fff;
}

.btn-primary:hover,
.btn-primary:focus-visible {
    background: #a00a0c;
    color: #fff;
}

.btn-secondary {
    background: #fff;
    color: #c90c0f;
    border-color: #c90c0f;
}

.btn-secondary:hover,
.btn-secondary:focus-visible {
    background: #c90c0f;
    color: #fff;
}

.tg-win-banner {
    display: none;
    position: absolute;
    inset: 0;
    align-items: center;
    justify-content: center;
    background: rgba(26, 18, 12, 0.45);
    color: #fff;
    font-size: 1.6rem;
    font-weight: 700;
    pointer-events: none;
}

.tg-board-wrap {
    position: relative;
}

.tg-win-banner.active {
    display: flex;
}

@media (max-width: 640px) {
    .tg-lcd {
        min-width: 4.2rem;
        font-size: 0.95rem;
    }

    .tg-tool-btn span {
        display: none;
    }

    .tg-board {
        min-height: 58vh;
    }
}
