/* Import shared game components */
@import url('../shared-game-components/common.css');

/* ========================================
   CHAIN 4 COLOR OVERRIDES
   ======================================== */

:root {
    /* Override shared button colors for Chain 4 theme */
    --btn-primary: #e94560;        /* Red for primary actions */
    --btn-primary-hover: #ff5577;
    --btn-secondary: #4a90e2;      /* Blue for secondary actions */
    --btn-secondary-hover: #5aa0f2;

    /* Chain 4 dark theme colors */
    --bg-primary: #2d2d2d;
    --bg-secondary: #1a1a1a;
    --border-color: #4a4a4a;
    --border-filled: #5a5a5a;

    /* Game-specific colors */
    --cell-bg: #3a3a3a;
    --cell-hover: #4a4a4a;
    --player-x: #e94560;  /* Red for X */
    --player-o: #4a90e2;  /* Blue for O */
    --combo-color: #ffd700; /* Gold for combos */
}

[data-theme="light"] {
    /* Override shared colors for Chain 4 light theme */
    --btn-primary: #dc2626;
    --btn-primary-hover: #ef4444;
    --btn-secondary: #2563eb;
    --btn-secondary-hover: #3b82f6;

    /* Chain 4 light theme colors */
    --bg-primary: #f0f4f8;
    --bg-secondary: #ffffff;
    --border-color: #cbd5e1;
    --border-filled: #94a3b8;

    /* Game-specific colors */
    --cell-bg: #ffffff;
    --cell-hover: #e0e7ff;
    --player-x: #dc2626;  /* Red for X */
    --player-o: #2563eb;  /* Blue for O */
    --combo-color: #eab308; /* Yellow for combos */
}

/* ========================================
   GAME-SPECIFIC COMPONENTS
   ======================================== */

.container {
    max-width: 700px;
    width: 100%;
    padding: 20px;
}

/* Override icon button hover to use game-specific color */
.icon-btn:hover {
    background-color: var(--cell-hover);
}

/* ========================================
   MODE SELECTOR
   ======================================== */

.mode-selector {
    display: flex;
    justify-content: center;
    gap: 12px;
    margin-bottom: 16px;
}

.mode-btn {
    background-color: var(--btn-secondary);
    border: none;
    color: white;
    font-size: 14px;
    font-weight: bold;
    padding: 12px 24px;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.mode-btn:hover {
    background-color: var(--btn-secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.mode-btn.active {
    background-color: var(--btn-primary);
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.mode-btn.active:hover {
    background-color: var(--btn-primary-hover);
}

.mode-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* ========================================
   SCORE DISPLAY
   ======================================== */

.score-display {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 30px;
    margin-bottom: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.score-item {
    display: flex;
    align-items: center;
    gap: 15px;
}

.score-icon {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
}

.score-icon svg {
    width: 100%;
    height: 100%;
}

.score-icon svg line {
    stroke: var(--player-x);
}

.score-icon svg circle {
    stroke: var(--player-o);
}

.score-value {
    text-align: center;
}

.score-number {
    font-size: 48px;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 5px;
}

.x-score .score-number {
    color: var(--player-x);
}

.o-score .score-number {
    color: var(--player-o);
}

.score-label {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.score-divider {
    font-size: 20px;
    font-weight: bold;
    color: var(--text-secondary);
    text-align: center;
}

.goal-text {
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 8px 12px;
    background-color: var(--bg-primary);
    border-radius: 8px;
}

/* ========================================
   GAME INFO
   ======================================== */

.game-info {
    text-align: center;
    margin-bottom: 20px;
}

.turn-indicator {
    font-size: 18px;
    font-weight: bold;
    padding: 10px;
    border-radius: 8px;
    background-color: var(--bg-secondary);
    margin-bottom: 10px;
}

.turn-indicator #current-player {
    color: var(--player-x);
    font-size: 24px;
}

.combo-display {
    font-size: 28px;
    font-weight: bold;
    color: var(--combo-color);
    text-transform: uppercase;
    letter-spacing: 2px;
    padding: 12px;
    border-radius: 8px;
    min-height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.combo-display.active {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
    animation: comboPulse 0.5s ease-in-out;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.3);
}

/* ========================================
   GAME BOARD
   ======================================== */

.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
}

.board {
    display: grid;
    gap: 10px;
    margin-bottom: 20px;
    padding: 20px;
    background-color: var(--bg-secondary);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.board-5x5 {
    grid-template-columns: repeat(5, 1fr);
}

.board-6x6 {
    grid-template-columns: repeat(6, 1fr);
}

.board-7x7 {
    grid-template-columns: repeat(7, 1fr);
}

.cell {
    background-color: var(--cell-bg);
    border: 3px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

/* 5x5 cells */
.board-5x5 .cell {
    width: 100px;
    height: 100px;
}

/* 6x6 cells */
.board-6x6 .cell {
    width: 85px;
    height: 85px;
}

/* 7x7 cells */
.board-7x7 .cell {
    width: 72px;
    height: 72px;
}

.cell:hover:not(.taken) {
    background-color: var(--cell-hover);
    transform: scale(1.05);
}

.cell.taken {
    cursor: not-allowed;
}

.cell .mark {
    animation: markAppear 0.3s ease-out;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.cell .mark svg {
    width: 100%;
    height: 100%;
}

.cell .mark.x svg {
    stroke: var(--player-x);
}

.cell .mark.o svg {
    stroke: var(--player-o);
}

.cell.marker-disappear {
    animation: markerDisappear 0.5s ease-out;
}

/* ========================================
   SHARE BUTTON
   ======================================== */

#share-container {
    text-align: center;
    margin-top: 20px;
}

.share-btn {
    background-color: var(--btn-secondary);
    border: none;
    border-radius: 8px;
    color: white;
    font-size: 16px;
    font-weight: bold;
    padding: 12px 32px;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.share-btn:hover {
    background-color: var(--btn-secondary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

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

/* ========================================
   MODAL CONTENT
   ======================================== */

/* Goal Box */
.goal-box {
    background: linear-gradient(135deg, var(--btn-primary) 0%, var(--btn-primary-hover) 100%);
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    margin: 20px 0;
    box-shadow: 0 4px 12px rgba(233, 69, 96, 0.4);
}

.goal-box strong {
    color: white;
    font-size: 18px;
    letter-spacing: 0.5px;
}

/* Visual Rules */
.rules-visual {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 15px 0;
}

.rule-item {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    padding: 15px;
    background-color: var(--bg-primary);
    border-radius: 8px;
    transition: transform 0.2s ease;
}

.rule-item:hover {
    transform: translateX(5px);
}

.rule-number {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--btn-primary) 0%, var(--btn-primary-hover) 100%);
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(233, 69, 96, 0.4);
}

.rule-content {
    flex: 1;
}

.rule-content strong {
    display: block;
    font-size: 16px;
    margin-bottom: 5px;
    color: var(--text-primary);
}

.rule-content p {
    margin: 0;
    font-size: 14px;
    line-height: 1.5;
    color: var(--text-secondary);
}

/* Inline Marks */
.inline-mark {
    display: inline-block;
    width: 20px;
    height: 20px;
    vertical-align: middle;
    margin: 0 2px;
}

.inline-mark svg {
    width: 100%;
    height: 100%;
}

#message .inline-mark {
    width: 24px;
    height: 24px;
}

.stat-label .inline-mark {
    width: 16px;
    height: 16px;
}

/* Scoring Table */
.scoring-table {
    margin: 20px 0;
    background-color: var(--bg-primary);
    border-radius: 8px;
    overflow: hidden;
}

.scoring-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--border-color);
}

.scoring-row:last-child {
    border-bottom: none;
}

.scoring-row.highlight {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.2) 0%, rgba(255, 215, 0, 0.1) 100%);
    font-weight: bold;
}

.combo-num {
    color: var(--text-primary);
    font-weight: 600;
}

.combo-points {
    color: var(--combo-color);
    font-weight: bold;
}

.scoring-note {
    font-size: 13px;
    color: var(--text-secondary);
    font-style: italic;
    margin-top: 10px;
}

/* Tips List */
.tips-list {
    margin-left: 20px;
    margin-bottom: 0;
}

.tips-list li {
    margin-bottom: 10px;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-secondary);
}

/* ========================================
   SETTINGS STYLES
   ======================================== */

/* Board Size Settings */
.size-setting {
    flex-direction: column;
    align-items: flex-start;
}

.size-toggle-container {
    margin-top: 10px;
    width: 100%;
}

.size-toggle-btn {
    background-color: var(--btn-secondary);
    border: none;
    border-radius: 20px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    gap: 4px;
    position: relative;
    transition: background-color 0.2s ease;
    width: 100%;
}

.size-toggle-btn:hover {
    background-color: var(--btn-secondary-hover);
}

.size-option {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    cursor: pointer;
}

.size-option.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.size-help {
    margin-top: 10px;
    width: 100%;
}

.size-description {
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    padding: 8px;
    background-color: var(--bg-primary);
    border-radius: 6px;
}

/* Difficulty Settings */
.difficulty-setting {
    flex-direction: column;
    align-items: flex-start;
}

.difficulty-toggle-container {
    margin-top: 10px;
    width: 100%;
}

.difficulty-toggle-btn {
    background-color: var(--btn-secondary);
    border: none;
    border-radius: 20px;
    padding: 4px;
    cursor: pointer;
    display: flex;
    gap: 4px;
    position: relative;
    transition: background-color 0.2s ease;
    width: 100%;
}

.difficulty-toggle-btn:hover {
    background-color: var(--btn-secondary-hover);
}

.difficulty-option {
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    padding: 8px 12px;
    border-radius: 16px;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: all 0.2s ease;
    cursor: pointer;
}

.difficulty-option.active {
    background-color: var(--bg-primary);
    color: var(--text-primary);
}

.difficulty-help {
    margin-top: 10px;
    width: 100%;
}

.difficulty-description {
    display: none;
    font-size: 13px;
    color: var(--text-secondary);
    margin: 0;
    padding: 8px;
    background-color: var(--bg-primary);
    border-radius: 6px;
}

.difficulty-description.active {
    display: block;
}

/* ========================================
   ANIMATIONS
   ======================================== */

@keyframes markAppear {
    from {
        transform: scale(0);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes markerDisappear {
    0% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.5;
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

@keyframes comboPulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes scoreUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
    }
    100% {
        transform: scale(1);
    }
}

.score-pulse {
    animation: scoreUpdate 0.5s ease-out;
}

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

/* Mobile responsive styles */
@media screen and (max-width: 700px) {
    .score-display {
        gap: 15px;
        padding: 15px;
    }

    .score-number {
        font-size: 36px;
    }

    .score-icon {
        width: 36px;
        height: 36px;
    }

    .goal-text {
        font-size: 12px;
    }

    .combo-display {
        font-size: 22px;
        min-height: 46px;
    }

    .board {
        gap: 8px;
        padding: 15px;
    }

    .cell {
        width: 70px;
        height: 70px;
        font-size: 36px;
    }

    .cell .mark {
        width: 48px;
        height: 48px;
    }

    .turn-indicator {
        font-size: 16px;
    }

    .rule-number {
        width: 32px;
        height: 32px;
        font-size: 16px;
    }

    .rule-item {
        padding: 12px;
        gap: 12px;
    }

    .rule-content strong {
        font-size: 15px;
    }

    .rule-content p {
        font-size: 13px;
    }
}

@media screen and (max-width: 500px) {
    .score-display {
        gap: 10px;
        padding: 12px;
    }

    .score-item {
        gap: 8px;
    }

    .score-number {
        font-size: 28px;
    }

    .score-icon {
        width: 28px;
        height: 28px;
    }

    .score-label {
        font-size: 11px;
    }

    .goal-text {
        font-size: 10px;
        padding: 6px 8px;
    }

    .combo-display {
        font-size: 18px;
        min-height: 40px;
        padding: 8px;
    }

    .cell {
        width: 54px;
        height: 54px;
        font-size: 28px;
    }

    .cell .mark {
        width: 38px;
        height: 38px;
    }

    .board {
        gap: 6px;
        padding: 10px;
    }

    .turn-indicator {
        font-size: 14px;
        padding: 8px;
    }

    .goal-box strong {
        font-size: 16px;
    }

    .scoring-row {
        padding: 10px 15px;
        font-size: 13px;
    }
}

@media screen and (max-width: 400px) {
    .cell {
        width: 48px;
        height: 48px;
        font-size: 24px;
        border-width: 2px;
    }

    .cell .mark {
        width: 34px;
        height: 34px;
    }

    .board {
        gap: 5px;
        padding: 8px;
    }

    .score-number {
        font-size: 24px;
    }

    .combo-display {
        font-size: 16px;
        letter-spacing: 1px;
    }
}
