/* Wordle Game Styles */

body {
    overflow-y: hidden;
}

/* Status Bar */
.status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2px 16px;
    margin-bottom: 8px;
    background-color: var(--bg-canvas-subtle);
    border-radius: 6px;
    border: 1px solid var(--border-default);
    width: 100%;
    max-width: 980px;
    margin-left: auto;
    margin-right: auto;
    margin-top: 0;
}

.timer {
    color: var(--fg-muted);
    font-size: 16px;
    font-weight: 500;
    margin: 4px 0;
}

.status-text {
    color: var(--fg-default);
    font-size: 20px;
    font-weight: 600;
    text-align: center;
    flex: 1;
    margin: 0 16px;
}

.status-text.error {
    color: rgb(212, 53, 69);
    animation: errorShake 0.5s ease-in-out;
}

.status-text.win {
    color: rgb(46, 160, 67);
    animation: winBounce 0.6s ease-in-out;
}

.score {
    color: var(--accent-fg);
    font-size: 16px;
    font-weight: 500;
    margin: 4px 0;
}

.status-buttons {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.status-buttons .help-button,
.status-buttons .stats-button {
    background-color: var(--bg-canvas-subtle, #21262d);
    border: 1px solid var(--border-default, #30363d);
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--fg-default, #F0F7EE);
    font-size: 1rem;
    font-weight: bold;
    flex-shrink: 0;
}

.status-buttons .help-button:hover,
.status-buttons .stats-button:hover {
    background-color: var(--btn-default-hover-bg, #30363d);
    transform: scale(1.1);
}

.status-buttons .help-icon,
.status-buttons .stats-icon {
    line-height: 1;
}

/* Responsive Design for Status Bar */
@media (max-width: 640px) {
    .status-bar {
        padding: 2px 10px;
        margin: 67px 1em 6px 1em;
        width: 90%;
    }

    .timer {
        font-size: 14px;
    }

    .status-text {
        font-size: 16px;
        margin: 0 8px;
    }

    .score {
        font-size: 14px;
    }

    .status-buttons .help-button,
    .status-buttons .stats-button {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
}

@media (max-width: 346px) {
    .status-bar {
        padding: 2px 10px;
    }

    .timer {
        font-size: 14px;
    }

    .status-text {
        font-size: 16px;
        margin: 0 8px;
    }

    .score {
        font-size: 14px;
    }

    .status-buttons .help-button,
    .status-buttons .stats-button {
        width: 26px;
        height: 26px;
        font-size: 0.8rem;
    }
}

@media (min-width: 641px) {
    .status-bar {
        margin-top: 80px;
    }
}

.wordle-main {
    height: calc(100vh - 80px);
    background-color: var(--bg-canvas, #0D1117);
    padding: 1rem 0 120px 0;
    display: flex;
    flex-direction: column;
}

.wordle-container {
    flex: 1;
    max-width: 600px;
    margin: 0 auto;
    padding: 0 1rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.wordle-game-content {
    flex: 1;
    overflow-y: auto;
    min-width: 420px;
}

.wordle-header {
    text-align: center;
    margin-bottom: 2rem;
}

.wordle-title {
    font-size: 3rem;
    font-weight: bold;
    color: var(--color-primary, #F0F7EE);
    margin: 0 0 0.5rem 0;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 0.2em;
}

.wordle-subtitle {
    font-size: 1.2rem;
    color: var(--color-primary, #F0F7EE);
    margin: 0;
    opacity: 0.9;
}

/* Game Board */
.wordle-board {
    background-color: var(--bg-canvas-subtle, #21262d);
    border-radius: 6px;
    padding: 1rem;
    margin-bottom: 108px;
    border: 1px solid var(--border-default, #30363d);
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Reduce margin when game is over to keep buttons visible */
.wordle-board:has(+ .game-over-buttons) {
    margin-bottom: 20px;
}

.wordle-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 8px;
    max-width: 360px;
    width: 100%;
    margin: 0 auto;
}

.wordle-row {
    display: contents;
}

.wordle-tile {
    aspect-ratio: 1;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--fg-default);
    font-size: 36px;
    font-family: ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace;
    padding: 0;
    background-color: var(--bg-canvas-subtle);
    border: 1px solid var(--border-accent);
    transition: all 0.2s ease;
    text-transform: uppercase;
    font-weight: bold;
    /* Prevent text selection */
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

.wordle-tile:hover {
    background-color: var(--bg-overlay);
    border-color: var(--fg-muted);
}

/* Wordle Tile States */
.wordle-tile.correct {
    background-color: rgb(46, 160, 67);
    border-color: rgb(46, 160, 67);
    color: white;
}

.wordle-tile.present {
    background-color: rgb(218, 154, 46);
    border-color: rgb(218, 154, 46);
    color: white;
}

.wordle-tile.absent {
    background-color: var(--bg-overlay);
    border-color: var(--border-muted);
    color: var(--fg-muted);
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

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

/* Modal Popup */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

.modal-overlay.show {
    display: flex;
    animation: modalFadeIn 0.3s ease-out;
}

.modal-content {
	background-color: var(--bg-canvas);
	border-radius: 12px;
	border: 1px solid var(--border-default);
	max-width: 600px;
	width: 90%;
	max-height: 90vh;
	overflow-y: auto;
	box-shadow: var(--shadow-large);
	animation: modalSlideIn 0.3s ease-out;
}

.modal-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 1.5rem 1.5rem 1rem 1.5rem;
	border-bottom: 1px solid var(--border-default);
}

.modal-title {
	font-size: 1.5rem;
	color: var(--fg-default);
	margin: 0;
	font-weight: 600;
}

.modal-close {
	background: none;
	border: none;
	color: var(--fg-default);
	font-size: 2rem;
	cursor: pointer;
	padding: 0;
	width: 40px;
	height: 40px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	transition: all 0.2s ease;
}

.modal-close:hover {
	background-color: var(--bg-overlay);
	transform: scale(1.1);
}

.modal-body {
    padding: 1.5rem;
}

.rules-content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1rem;
}

.rule-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: var(--background-color-primary, #0D1117);
    border-radius: 6px;
    border: 1px solid var(--border-color, #30363d);
}

.rule-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.rule-text {
    color: var(--color-primary, #F0F7EE);
    font-size: 0.9rem;
    line-height: 1.4;
}

@keyframes modalFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes modalSlideIn {
    from { 
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to { 
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Wordle Actions */
.wordle-actions {
    margin-top: 2rem;
    text-align: center;
}

.action-buttons {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.action-buttons .btn {
    padding: 0.75rem 1.5rem;
    border-radius: 6px;
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 120px;
}

.action-buttons .btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.action-buttons .btn-primary {
    background-color: rgb(46, 160, 67);
    color: white;
}

.action-buttons .btn-primary:hover:not(:disabled) {
    background-color: rgb(38, 133, 55);
    transform: translateY(-1px);
}

.action-buttons .btn-secondary {
    background-color: var(--bg-secondary, #21262d);
    color: var(--color-primary, #F0F7EE);
    border: 1px solid var(--border-color, #30363d);
}

.action-buttons .btn-secondary:hover:not(:disabled) {
    background-color: var(--border-color, #30363d);
    transform: translateY(-1px);
}

.action-note {
    margin-top: 1rem;
    color: var(--color-secondary, #8B949E);
    font-size: 0.8rem;
    text-align: center;
}

@media (max-width: 768px) {
    .wordle-main {
        height: calc(100vh - 80px);
        padding: 0.5rem 0 100px 0;
    }

    .wordle-game-content {
        padding: 0 0.5rem;
        min-width: 400px;
    }

    .wordle-game-title {
        font-size: 1.7rem;
    }

    .wordle-title {
        font-size: 2.5rem;
    }

    .wordle-tile {
        font-size: 28px;
    }

    .rules-content {
        grid-template-columns: 1fr;
    }

    .action-buttons {
        flex-direction: column;
        align-items: center;
    }

    .action-buttons .btn {
        width: 100%;
        max-width: 300px;
    }

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

    .chart-bars {
        height: 124px;
    }

    .chart-bar-value {
        font-size: 0.6rem;
        top: -20px;
    }
}

@media (max-width: 480px) {
    .wordle-main {
        height: calc(100vh - 80px);
        padding: 0.5rem 0 80px 0;
    }

    .wordle-game-content {
        padding: 0 0.25rem;
        min-width: 320px;
    }

    .wordle-container {
        padding: 0 0.5rem;
    }

    .wordle-game-title {
        font-size: 1.3rem;
    }

    .help-button,
    .stats-button {
        width: 32px;
        height: 32px;
        font-size: 1.2rem;
    }

    .wordle-board {
        padding: 1rem;
    }

    .wordle-tile {
        font-size: 24px;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-header {
        padding: 1rem 1rem 0.75rem 1rem;
    }

    .modal-body {
        padding: 1rem;
    }

    .stats-modal-content {
        max-width: 95%;
        max-height: 90vh;
    }

    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .stat-card {
        padding: 0.5rem;
    }

    .stat-value {
        font-size: 1.2rem;
    }

    .stat-label {
        font-size: 0.7rem;
    }

    .chart-container {
        padding: 1rem;
    }

    .chart-bars {
        height: 104px;
        gap: 2px;
    }

    .chart-bar-value {
        font-size: 0.5rem;
        top: -18px;
    }

    .chart-labels {
        font-size: 0.7rem;
    }
}

@media (max-width: 640px) {
    .wordle-grid {
        max-width: 300px;
    }
}

@media (max-width: 346px) {
    .wordle-game-content {
        min-width: 300px;
    }
    .wordle-grid {
        max-width: 240px;
    }
    .wordle-tile {
        font-size: 18px;
    }
}

.key-button.correct {
    background-color: rgb(46, 160, 67);
    border-color: rgb(46, 160, 67);
    color: white;
}

.key-button.correct:hover {
    background-color: rgb(38, 133, 55);
}

.key-button.present {
    background-color: rgb(218, 154, 46);
    border-color: rgb(218, 154, 46);
    color: white;
}

.key-button.present:hover {
    background-color: rgb(194, 137, 41);
}

.key-button.absent {
    /* background-color: rgb(48, 54, 61);
    border-color: rgb(48, 54, 61);
    color: rgb(139, 148, 158); */
    opacity: 0.5;
    cursor: not-allowed;
}

/* Statistics Modal Specific Styles */
.stats-modal-content {
    max-width: 700px;
    max-height: 85vh;
}

.stats-loading {
	text-align: center;
	padding: 2rem;
	color: var(--fg-default);
}

.loading-spinner {
	width: 40px;
	height: 40px;
	border: 4px solid var(--border-default);
	border-top: 4px solid var(--accent-fg);
	border-radius: 50%;
	animation: spin 1s linear infinite;
	margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.stats-content {
	color: var(--fg-default);
}

.stats-section {
    margin-bottom: 2rem;
}

.stats-section:last-child {
    margin-bottom: 0;
}

.stats-section-title {
	font-size: 1.2rem;
	font-weight: 600;
	margin: 0 0 1rem 0;
	color: var(--fg-default);
	border-bottom: 1px solid var(--border-default);
	padding-bottom: 0.5rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 0.75rem;
}

.stat-card {
	background-color: var(--bg-canvas-subtle);
	border: 1px solid var(--border-default);
	border-radius: 8px;
	padding: 0.5rem 0.75rem;
	text-align: center;
	color: var(--fg-default);
}

.stat-value {
	font-size: 1.3rem;
	font-weight: bold;
	color: var(--fg-default);
	margin-bottom: 0.25rem;
}

.stat-label {
	font-size: 0.75rem;
	color: var(--fg-muted);
	line-height: 1.2;
}

/* Chart Styles */
.chart-container {
	background-color: var(--bg-canvas-subtle);
	border: 1px solid var(--border-default);
	border-radius: 8px;
	padding: 1.5rem;
}

.chart-bars {
    display: flex;
    align-items: end;
    gap: 4px;
    height: 144px;
    padding-top: 1.5rem; /* room for the value label above the tallest bar */
    margin-bottom: 0.5rem;
}

.chart-bar {
	flex: 1;
	background-color: var(--border-default);
	border-radius: 2px 2px 0 0;
	min-height: 4px;
	position: relative;
	transition: all 0.3s ease;
}

.chart-bar.has-data {
    background-color: rgb(46, 160, 67);
}

.chart-bar.did-not-find {
    background-color: rgb(212, 53, 69);
}

.chart-bar-value {
	position: absolute;
	top: -25px;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.7rem;
	color: var(--fg-default);
	font-weight: 500;
}

.did-not-find-label {
    color: rgb(212, 53, 69) !important;
    font-weight: 600 !important;
}

.chart-labels {
	display: flex;
	justify-content: space-between;
	font-size: 0.8rem;
	color: var(--fg-muted);
}

.chart-labels span {
	flex: 1;
	text-align: center;
	color: var(--fg-default);
	font-weight: 500;
}

/* Yesterday's Results */
.yesterday-stats {
	background-color: var(--bg-canvas-subtle);
	border: 1px solid var(--border-default);
	border-radius: 8px;
	padding: 1rem;
}

.yesterday-summary {
	display: flex;
	justify-content: space-between;
	align-items: center;
	margin-bottom: 1rem;
	padding-bottom: 0.5rem;
	border-bottom: 1px solid var(--border-default);
}

.yesterday-user-result {
	background-color: var(--bg-canvas-subtle);
	border: 1px solid var(--border-default);
	border-radius: 6px;
	padding: 0.75rem;
	margin-bottom: 1rem;
}

.yesterday-user-result h4 {
	margin: 0 0 0.5rem 0;
	font-size: 1rem;
	color: var(--fg-default);
}

.yesterday-words {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.yesterday-word-row {
    display: flex;
    gap: 2px;
}

.yesterday-word {
	background-color: var(--bg-canvas);
	border: 1px solid var(--border-default);
	border-radius: 4px;
	padding: 0.25rem 0.5rem;
	font-size: 0.8rem;
	font-family: monospace;
	color: var(--fg-default);
}

.yesterday-word.correct {
    background-color: rgb(46, 160, 67);
    border-color: rgb(46, 160, 67);
    color: white;
}

.yesterday-word.present {
    background-color: rgb(218, 154, 46);
    border-color: rgb(218, 154, 46);
    color: white;
}

.yesterday-word.absent {
    background-color: var(--bg-overlay);
    border-color: var(--border-muted);
    color: var(--fg-muted);
}

.no-yesterday-data {
	text-align: center;
	color: var(--fg-muted);
	font-style: italic;
	padding: 1rem;
}

.stats-icon svg {
    display: block;
    width: 1em;
    height: 1em;
    margin: 0 auto;
    vertical-align: middle;
}

/* Fullscreen Mode Styles for Wordle */
:fullscreen .wordle-main,
:-webkit-full-screen .wordle-main,
:-moz-full-screen .wordle-main,
:-ms-fullscreen .wordle-main {
    height: calc(100vh - var(--header-height));
    padding: 0.5rem 0 60px 0;
}

:fullscreen .wordle-container,
:-webkit-full-screen .wordle-container,
:-moz-full-screen .wordle-container,
:-ms-fullscreen .wordle-container {
    max-width: 800px;
    padding: 0 2rem;
}

:fullscreen .wordle-board,
:-webkit-full-screen .wordle-board,
:-moz-full-screen .wordle-board,
:-ms-fullscreen .wordle-board {
    margin: 1rem auto;
    max-width: 500px;
}

:fullscreen .wordle-tile,
:-webkit-full-screen .wordle-tile,
:-moz-full-screen .wordle-tile,
:-ms-fullscreen .wordle-tile {
    width: 60px;
    height: 60px;
    font-size: 1.5rem;
}

@media (max-width: 768px) {
    :fullscreen .wordle-tile,
    :-webkit-full-screen .wordle-tile,
    :-moz-full-screen .wordle-tile,
    :-ms-fullscreen .wordle-tile {
        width: 50px;
        height: 50px;
        font-size: 1.3rem;
    }
}

/* Wordle Spinner Styles */
.wordle-spinner {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    border-radius: 8px;
}

.spinner-content {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid var(--color-primary, #F0F7EE);
    border-radius: 50%;
    animation: wordleSpin 1s linear infinite;
}

@keyframes wordleSpin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Ensure the wordle board has relative positioning for the spinner */
.wordle-board {
    position: relative;
}

/* Game Over Buttons */
.game-over-buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1.5rem;
    margin: 1rem auto 2rem;
    max-width: 480px;
    padding: 0 1rem;
}

.game-over-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    padding: 1rem 1.5rem;
    background-color: var(--bg-canvas-subtle);
    border: 1px solid var(--border-default);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--fg-default);
    font-size: 0.9rem;
    font-weight: 500;
    text-align: center;
    min-width: 120px;
}

.game-over-button:hover {
    background-color: var(--btn-default-hover-bg);
    border-color: var(--accent-fg);
    transform: translateY(-2px);
}

.game-over-button:active {
    transform: translateY(0);
}

.game-over-button svg {
    width: 24px;
    height: 24px;
    margin-bottom: 0.25rem;
}

@media (max-width: 640px) {
    .game-over-buttons {
        flex-direction: row;
        gap: 1rem;
        margin: 0.5rem auto 1rem;
        padding: 0 0.5rem;
        display: grid;
        grid-auto-flow: column;
        grid-auto-columns: 1fr;
    }
    
    .game-over-button {
        padding: 0.75rem 0.5rem;
        font-size: 0.8rem;
        width: 100%;
        box-sizing: border-box;
    }
    
    .game-over-button svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .game-over-buttons {
        gap: 0.75rem;
        margin: 0.5rem auto 0.5rem;
    }
    
    .game-over-button {
        padding: 0.6rem 0.4rem;
        font-size: 0.75rem;
        height: auto;
    }
}

/* Guest play - a random past word, with prompts to register for the word of the day */
.guest-cta-line {
	max-width: 480px;
	margin: 1rem auto;
	padding: 0 1rem;
	text-align: center;
	font-size: 0.85rem;
	color: var(--fg-muted);
}

.guest-cta-line a {
	color: var(--accent-fg);
}

.guest-stats-pending {
	text-align: center;
	color: var(--fg-muted);
	font-size: 0.9rem;
}

.guest-cta {
	margin-top: 1.5rem;
	padding: 1rem;
	text-align: center;
	background-color: var(--bg-canvas-subtle);
	border: 1px solid var(--border-default);
	border-radius: 8px;
	color: var(--fg-default);
}

.guest-cta h3 {
	margin-bottom: 0.5rem;
}

.guest-cta-buttons {
	display: flex;
	gap: 1rem;
	justify-content: center;
	margin-top: 1rem;
}
