/* Chessgi Arena - Mobile-first centered layout */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', 'Hiragino Kaku Gothic ProN', 'Noto Sans JP', sans-serif;
    background: #000000;
    color: #e0e0e0;
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ============ Settings Dialog ============ */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.settings-dialog {
    background: #2a2a3e;
    border: 1px solid #555;
    border-radius: 12px;
    padding: 24px;
    max-width: 420px;
    width: 88%;
    text-align: center;
}

.settings-dialog h3 {
    color: #f0d080;
    font-size: 20px;
    margin-bottom: 16px;
}

.settings-label {
    color: #ccc;
    font-size: 14px;
    margin-bottom: 12px;
    text-align: left;
}

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

.settings-option {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 12px 14px;
    background: #1a1a2e;
    border: 2px solid transparent;
    border-radius: 8px;
    cursor: pointer;
    text-align: left;
    color: #e0e0e0;
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.15s;
}

.settings-option:hover {
    border-color: #555;
}

.settings-option.selected {
    background: #2a3a2a;
    border-color: #6aaa6a;
}

.settings-radio {
    font-size: 14px;
    color: #666;
}

.settings-option.selected .settings-radio {
    color: #6aaa6a;
}

.settings-option-text {
    display: flex;
    flex-direction: column;
}

.settings-option-label {
    font-size: 15px;
    font-weight: bold;
}

.settings-option-preview {
    font-size: 13px;
    color: #999;
    margin-top: 2px;
}

.title-bottom-btns {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 12px;
}

.title-small-btn {
    background: none;
    border: 1px solid #333;
    border-radius: 6px;
    color: #666;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 16px;
    transition: color 0.15s, border-color 0.15s;
}

.title-small-btn:hover {
    color: #aaa;
    border-color: #555;
}

/* ============ Title Screen ============ */
.title-screen {
    display: flex;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    align-items: center;
    justify-content: center;
    z-index: 50;
    background: #000000;
}

.title-content {
    text-align: center;
    max-width: 520px;
    width: 92%;
}

.title-king {
    font-size: 64px;
    color: #f0d080;
    margin-bottom: 8px;
}

.title-main {
    font-size: 28px;
    color: #f0d080;
    letter-spacing: 3px;
    margin-bottom: 4px;
}

.title-sub {
    font-size: 14px;
    color: #999;
    margin-bottom: 36px;
}

.title-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.title-btn {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 14px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    transition: transform 0.1s, box-shadow 0.15s;
    font-family: inherit;
}

.title-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}

.title-btn:active {
    transform: translateY(0);
}

.title-btn-online {
    background: #4a7a4a;
    color: #fff;
}

.title-btn-ai {
    background: #4a4a7a;
    color: #fff;
}

.title-btn-analysis {
    background: #6a5a3a;
    color: #fff;
}

.title-btn-bullet {
    background: #7a3a3a;
    color: #fff;
}

.title-btn-rapid {
    background: #3a6a5a;
    color: #fff;
}

.title-btn-history {
    background: #4a4a5a;
    color: #fff;
}

.title-btn-ranking {
    background: #5a4a6a;
    color: #fff;
}

.title-btn-icon {
    font-size: 24px;
    flex-shrink: 0;
}

.title-btn-text {
    display: flex;
    flex-direction: column;
}

.title-btn-label {
    font-size: 16px;
    font-weight: bold;
}

.title-btn-desc {
    font-size: 11px;
    opacity: 0.7;
    margin-top: 2px;
}

/* ============ Online Waiting ============ */
.online-waiting {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: #000000;
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
}

.waiting-content {
    text-align: center;
}

.waiting-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid #333;
    border-top-color: #f0d080;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 24px;
}

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

.waiting-text {
    font-size: 20px;
    color: #e0e0e0;
    margin-bottom: 8px;
}

.waiting-name {
    font-size: 14px;
    color: #999;
}

/* ============ Header ============ */
header {
    text-align: center;
    padding: 8px 0 4px;
    width: 100%;
    max-width: 520px;
}

.header-row {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 0 8px;
}

.back-btn {
    background: none;
    border: 1px solid #555;
    color: #e0e0e0;
    padding: 5px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
    white-space: nowrap;
}

.back-btn:hover {
    background: #3a3a5e;
}

header h1 {
    font-size: 20px;
    color: #f0d080;
    letter-spacing: 2px;
}

header .subtitle {
    font-size: 11px;
    color: #999;
    margin-top: 1px;
}

/* ============ Clock ============ */
.clock-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 5px 12px;
    background: #2a2a3e;
    border-radius: 6px;
    border: 1px solid transparent;
}

.clock-bar.clock-active {
    background: #2a3a2e;
    border-color: #4a7a4a;
}

.clock-name {
    font-size: 12px;
    color: #999;
}

.clock-bar.clock-mine .clock-name {
    color: #f0d080;
}

.clock-time {
    font-size: 20px;
    font-weight: bold;
    font-family: 'Courier New', monospace;
    color: #fff;
}

.clock-time.clock-warning {
    color: #ffa500;
}

.clock-time.clock-danger {
    color: #ff4444;
    animation: pulse 0.5s ease-in-out infinite;
}

/* ============ Main layout - single column, centered ============ */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: 520px;
    padding: 0 8px 12px;
    gap: 0;
}

.board-area {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
}

/* Board */
#board {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    grid-template-rows: repeat(8, 1fr);
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #63451a;
    box-shadow: 0 2px 12px rgba(0,0,0,0.5);
}

.square {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.square.light {
    background-color: #f0d9a0;
}

.square.dark {
    background-color: #c4a45a;
}

.square.selected {
    background-color: #aad751 !important;
}

.square.last-move {
    background-color: #cdd26a !important;
}

.square.in-check {
    background: radial-gradient(circle, #ff0000 0%, #cc000080 50%, transparent 70%) !important;
}

/* Piece */
.piece {
    width: 90%;
    height: 90%;
    object-fit: contain;
    z-index: 1;
    pointer-events: none;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.piece.promoted-pawn {
    /* Visual distinction via P label */
}

/* Chess style promoted piece wrapper */
.piece-promoted-wrapper {
    position: relative;
    width: 90%;
    height: 90%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
    pointer-events: none;
}

.piece-promoted-wrapper .piece-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.piece-promoted-label {
    position: absolute;
    top: 0;
    left: 2px;
    font-size: 14px;
    font-weight: 900;
    pointer-events: none;
    z-index: 2;
    line-height: 1;
}

.piece-promoted-label.promo-on-white {
    color: #fff;
    text-shadow: 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
}

.piece-promoted-label.promo-on-black {
    color: #000;
    text-shadow: 1px 1px 0 #fff, -1px -1px 0 #fff, 1px -1px 0 #fff, -1px 1px 0 #fff;
}

/* Move hints */
.move-hint {
    position: absolute;
    width: 28%;
    height: 28%;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.18);
    z-index: 2;
    pointer-events: none;
}

.capture-hint {
    position: absolute;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 3px solid rgba(0, 0, 0, 0.25);
    z-index: 0;
    pointer-events: none;
    box-sizing: border-box;
}

/* Coordinates */
.coord {
    position: absolute;
    font-size: 9px;
    font-weight: bold;
    pointer-events: none;
    z-index: 3;
}

.coord.rank {
    top: 1px;
    left: 2px;
    color: #63451a;
}

.coord.file {
    bottom: 1px;
    right: 2px;
    color: #63451a;
}

/* Hands */
.hand-container {
    height: 68px;
    width: 100%;
    background: #2a2a3e;
    border-radius: 6px;
    padding: 4px 8px;
    overflow: hidden;
}

.hand-label {
    font-size: 11px;
    color: #aaa;
    margin-bottom: 2px;
}

.hand-pieces {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    align-items: center;
}

.hand-piece {
    position: relative;
    width: 44px;
    height: 48px;
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: border-color 0.15s;
}

.hand-piece:hover {
    border-color: #aad751;
}

.hand-piece.selected {
    border-color: #aad751;
    background: rgba(170, 215, 81, 0.2);
}

.hand-piece.inactive {
    opacity: 0.5;
    cursor: default;
}

.hand-piece.inactive:hover {
    border-color: transparent;
}

.hand-piece-img {
    width: 36px;
    height: 40px;
    object-fit: contain;
    pointer-events: none;
    filter: drop-shadow(1px 1px 1px rgba(0,0,0,0.3));
}

.hand-count {
    position: absolute;
    bottom: 0;
    right: 2px;
    font-size: 12px;
    font-weight: bold;
    color: #fff;
    text-shadow: 0 0 3px #000, 0 0 6px #000;
}

.hand-empty {
    font-size: 11px;
    color: #666;
    padding: 6px 0;
}

/* Side panel - now below board in single column */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
}

/* Status */
.status {
    font-size: 16px;
    font-weight: bold;
    padding: 8px 12px;
    background: #2a2a3e;
    border-radius: 6px;
    text-align: center;
}

.status.game-over {
    background: #3a2020;
    color: #ff8888;
}

.status.ai-thinking {
    background: #2a3a2e;
    color: #88cc88;
    animation: pulse 1s ease-in-out infinite;
}

.status.waiting-turn {
    color: #999;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Buttons */
.controls {
    display: flex;
    gap: 8px;
}

.controls button {
    flex: 1;
    padding: 8px 10px;
    font-size: 13px;
    background: #3a3a5e;
    color: #e0e0e0;
    border: 1px solid #555;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.controls button:hover {
    background: #4a4a7e;
}

.resign-confirm {
    background: #7a3a3a !important;
}

.resign-confirm:hover {
    background: #9a4a4a !important;
}

/* Move list */
.move-list-container {
    background: #2a2a3e;
    border-radius: 6px;
    padding: 6px 8px;
}

.move-list-container h3 {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}

#move-list {
    max-height: 200px;
    overflow-y: auto;
    font-size: 12px;
}

.move-entry {
    padding: 2px 4px;
    border-bottom: 1px solid #333;
}

.move-num {
    color: #888;
    min-width: 24px;
    display: inline-block;
}

.move-sente {
    color: #e0d0a0;
}

.move-gote {
    color: #a0c0e0;
}

/* Rules panel */
.rules-container {
    background: #2a2a3e;
    border-radius: 6px;
    padding: 6px 10px;
}

.rules-container h3 {
    font-size: 12px;
    color: #aaa;
    margin-bottom: 4px;
}

.rules-container ul {
    font-size: 11px;
    color: #999;
    padding-left: 16px;
    line-height: 1.5;
}

/* Dialog */
.dialog-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.dialog-content {
    background: #2a2a3e;
    border: 1px solid #555;
    border-radius: 8px;
    padding: 20px;
    max-width: 420px;
    width: 88%;
    text-align: center;
}

.dialog-content h3 {
    color: #f0d080;
    margin-bottom: 12px;
    font-size: 18px;
}

.dialog-content p {
    color: #ccc;
    margin-bottom: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.dialog-buttons {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
}

.dialog-btn, .promo-btn {
    padding: 8px 20px;
    font-size: 14px;
    background: #4a4a7e;
    color: #e0e0e0;
    border: 1px solid #666;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s;
}

.dialog-btn:hover, .promo-btn:hover {
    background: #6a6aae;
}

.promo-btn {
    min-width: 80px;
}

/* Scrollbar */
#move-list::-webkit-scrollbar {
    width: 5px;
}

#move-list::-webkit-scrollbar-track {
    background: #1a1a2e;
}

#move-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

/* ============ Login Section ============ */
.login-section {
    margin-top: 12px;
    text-align: center;
}
.login-row {
    display: flex;
    gap: 6px;
    justify-content: center;
    flex-wrap: wrap;
    margin-bottom: 6px;
}
.login-input {
    background: #2a2a3e;
    border: 1px solid #555;
    color: #e0e0e0;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 13px;
    width: 120px;
}
.login-input:focus {
    outline: none;
    border-color: #aad751;
}
.login-btn {
    background: #aad751;
    color: #1a1a2e;
    border: none;
    padding: 6px 14px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 13px;
    font-weight: bold;
}
.login-btn:hover {
    background: #bbea62;
}
.login-error {
    color: #ff6b6b;
    font-size: 12px;
    margin-top: 4px;
}
.toggle-login-btn {
    background: none;
    border: 1px solid #555;
    color: #aaa;
    padding: 4px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}
.toggle-login-btn:hover {
    border-color: #aad751;
    color: #aad751;
}
.user-display {
    color: #aad751;
    font-size: 14px;
    font-weight: bold;
}
.logout-btn {
    background: none;
    border: 1px solid #666;
    color: #999;
    padding: 3px 10px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 11px;
    margin-left: 8px;
}
.logout-btn:hover {
    border-color: #ff6b6b;
    color: #ff6b6b;
}
.elo-badge {
    background: #3a3a5e;
    color: #f0d080;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    margin-left: 6px;
}
.elo-change {
    font-size: 12px;
    font-weight: bold;
    margin-left: 4px;
}
.elo-change.positive { color: #aad751; }
.elo-change.negative { color: #ff6b6b; }

/* ============ Game Over Result Overlay ============ */
.result-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 150;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-content {
    text-align: center;
    max-width: 320px;
    width: 88%;
}

.result-title {
    font-size: 36px;
    font-weight: bold;
    margin-bottom: 8px;
}

.result-title.win { color: #aad751; }
.result-title.lose { color: #ff6b6b; }
.result-title.draw { color: #e0e0e0; }

.result-elo-change {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 4px;
}

.result-elo-change.positive { color: #aad751; }
.result-elo-change.negative { color: #ff6b6b; }
.result-elo-change.zero { color: #999; }

.result-new-elo {
    font-size: 14px;
    color: #999;
    margin-bottom: 20px;
}

.result-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.result-btn {
    padding: 12px 20px;
    font-size: 15px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-family: inherit;
    font-weight: bold;
}

.result-btn-continue {
    background: #4a7a4a;
    color: #fff;
}

.result-btn-title {
    background: #3a3a5e;
    color: #e0e0e0;
}

.result-btn-review {
    background: #6a5a3a;
    color: #e0e0e0;
}

/* ============ No responsive breakpoint needed ============ */
/* Everything is already mobile-first, max-width: 420px, centered */
