/* ============================================
   DAILY WORDLE PUZZLE - FINAL RESPONSIVE CSS
   ============================================ */

:root {
    --bg-color: #ffffff;
    --text-color: #1a1a1b;
    --text-secondary: #6b7280;
    --border-color: #d3d6da;
    --tile-border: #d3d6da;
    --key-bg: #d3d6da;
    --key-text: #1a1a1b;
    --green: #6aaa64;
    --yellow: #c9b458;
    --gray: #787c7e;
    --accent: #6aaa64;
    --font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
    --bg-color: #121213;
    --text-color: #ffffff;
    --text-secondary: #9ca3af;
    --border-color: #3a3a3c;
    --tile-border: #3a3a3c;
    --key-bg: #818384;
    --key-text: #ffffff;
}

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

html, body {
    height: 100%;
    overflow-x: hidden;
    -webkit-text-size-adjust: 100%;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: var(--font-family);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    transition: background 0.3s, color 0.3s;
    line-height: 1.6;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 12px;
}

/* ============================================
   HEADER (NOT STICKY)
   ============================================ */
.site-header {
    border-bottom: 1px solid var(--border-color);
    padding: 10px 0;
    background: var(--bg-color);
    width: 100%;
}

.header-inner {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
}

.logo {
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 700;
    text-decoration: none;
    color: var(--text-color);
    white-space: nowrap;
}

.main-nav {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.main-nav a {
    text-decoration: none;
    color: var(--text-color);
    font-size: clamp(0.7rem, 2.5vw, 0.9rem);
    font-weight: 500;
    white-space: nowrap;
}

.main-nav a:hover { color: var(--accent); }

.icon-btn {
    background: none;
    border: none;
    font-size: clamp(1rem, 3vw, 1.2rem);
    cursor: pointer;
    padding: 4px;
    color: var(--text-color);
}

/* ============================================
   GAME CONTAINER
   ============================================ */
.game-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px 0;
    flex: 1;
    width: 100%;
}

.game-header {
    text-align: center;
    margin-bottom: 12px;
    width: 100%;
}

.game-header h1 {
    font-size: clamp(1.2rem, 5vw, 2rem);
    margin-bottom: 4px;
}

.game-header p {
    color: var(--text-secondary);
    font-size: clamp(0.75rem, 2.5vw, 0.95rem);
}

.puzzle-number {
    font-weight: 600;
    color: var(--accent) !important;
}

/* ============================================
   WORD SIZE CONTROLS
   ============================================ */
.game-controls-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    align-items: flex-end;
    flex-wrap: wrap;
    margin-bottom: 12px;
    width: 100%;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.control-item label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.control-item select {
    padding: 6px 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    min-width: 70px;
}

.control-item select:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

/* ============================================
   GAME BOARD - FIXED RESPONSIVE
   ============================================ */
.game-board {
    display: grid;
    gap: 5px;
    margin: 12px auto;
    /* Default 5-letter width */
    width: min(90vw, 330px);
    /* Total grid aspect ratio: 5 cols × 6 rows = 5/6 */
    aspect-ratio: 5 / 6;
    max-width: 100%;
}

/* Dynamic sizing based on word length */
.game-board[data-length="2"] { width: min(40vw, 130px); aspect-ratio: 2 / 6; }
.game-board[data-length="3"] { width: min(55vw, 190px); aspect-ratio: 3 / 6; }
.game-board[data-length="4"] { width: min(70vw, 240px); aspect-ratio: 4 / 6; }
.game-board[data-length="5"] { width: min(90vw, 330px); aspect-ratio: 5 / 6; }
.game-board[data-length="6"] { width: min(95vw, 380px); aspect-ratio: 6 / 6; }
.game-board[data-length="7"] { width: min(98vw, 420px); aspect-ratio: 7 / 6; }
.game-board[data-length="8"] { width: min(98vw, 460px); aspect-ratio: 8 / 6; }
.game-board[data-length="9"] { width: min(98vw, 500px); aspect-ratio: 9 / 6; }
.game-board[data-length="10"] { width: min(98vw, 540px); aspect-ratio: 10 / 6; }

.row {
    display: grid;
    gap: 5px;
    /* Each row fills the height proportionally */
    grid-template-columns: repeat(5, 1fr);
}

/* Tile: Square, responsive, well-sized */
.tile {
    width: 100%;
    aspect-ratio: 1 / 1;
    border: 2px solid var(--tile-border);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1rem, 5vw, 1.8rem);
    font-weight: bold;
    text-transform: uppercase;
    user-select: none;
    color: var(--text-color);
    background: var(--bg-color);
    transition: transform 0.2s, background 0.3s;
    line-height: 1;
    padding: 0;
}

.tile[data-state="green"] { background-color: var(--green); color: white; border-color: var(--green); }
.tile[data-state="yellow"] { background-color: var(--yellow); color: white; border-color: var(--yellow); }
.tile[data-state="gray"] { background-color: var(--gray); color: white; border-color: var(--gray); }

/* ============================================
   KEYBOARD - FULLY RESPONSIVE
   ============================================ */
.keyboard {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 100%;
    max-width: min(95vw, 500px);
    margin: 12px auto 0;
    padding: 0 4px;
}

.keyboard-row {
    display: flex;
    justify-content: center;
    gap: 4px;
    width: 100%;
}

.key {
    background-color: var(--key-bg);
    color: var(--key-text);
    border: none;
    border-radius: 4px;
    padding: 0;
    height: clamp(36px, 8vw, 52px);
    flex: 1;
    font-weight: bold;
    text-transform: uppercase;
    cursor: pointer;
    font-size: clamp(0.65rem, 2.5vw, 0.95rem);
    min-width: 0;
    transition: background 0.2s;
    user-select: none;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
}

.key:active { transform: scale(0.95); }
.key.wide { flex: 1.5; }
.key[data-state="green"] { background-color: var(--green); color: white; }
.key[data-state="yellow"] { background-color: var(--yellow); color: white; }
.key[data-state="gray"] { background-color: var(--gray); color: white; }

/* ============================================
   GAME ACTIONS
   ============================================ */
.game-actions {
    display: flex;
    gap: 10px;
    margin-top: 12px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
}

.btn {
    padding: 10px 16px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    font-weight: 600;
    font-size: clamp(0.75rem, 2.5vw, 0.9rem);
    transition: opacity 0.2s;
    min-width: 100px;
}

.btn:hover { opacity: 0.9; }
.btn-primary { background-color: var(--accent); color: white; }
.btn-secondary { background-color: var(--key-bg); color: var(--key-text); }

.game-message {
    margin-top: 12px;
    font-size: clamp(0.85rem, 3vw, 1rem);
    font-weight: 600;
    text-align: center;
    min-height: 24px;
    padding: 0 8px;
}

/* ============================================
   ADSENSE AD SLOTS - RESPONSIVE
   ============================================ */
.ad-slot {
    width: 100%;
    max-width: 728px;
    margin: 16px auto;
    min-height: 90px;
    background: transparent;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    position: relative;
    padding: 0 8px;
}

.ad-slot ins {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 60px;
}

/* ============================================
   MODALS
   ============================================ */
.modal {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    padding: 16px;
}
.modal.hidden { display: none; }
.modal-content {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 24px;
    border-radius: 12px;
    width: 100%;
    max-width: 420px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}
.close-modal {
    position: absolute;
    top: 12px; right: 16px;
    font-size: 1.5rem;
    cursor: pointer;
    background: none;
    border: none;
    color: var(--text-color);
}
.modal-content h2 { margin-bottom: 16px; }
.modal-content label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 12px 0;
    cursor: pointer;
    font-size: 0.95rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
    text-align: center;
}
.stat-item { display: flex; flex-direction: column; }
.stat-value { font-size: 1.5rem; font-weight: bold; }
.stat-label { font-size: 0.75rem; color: var(--text-secondary); }

.distribution { margin-top: 16px; }
.dist-row { display: flex; align-items: center; gap: 8px; margin: 4px 0; }
.dist-bar {
    background: var(--gray);
    color: white;
    padding: 2px 8px;
    font-size: 0.8rem;
    border-radius: 3px;
    min-width: 24px;
    text-align: center;
}

/* ============================================
   ANIMATIONS
   ============================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    75% { transform: translateX(6px); }
}
.shake { animation: shake 0.3s ease-in-out; }

@keyframes flip {
    0% { transform: rotateX(0); }
    50% { transform: rotateX(90deg); }
    100% { transform: rotateX(0); }
}
.flip { animation: flip 0.5s ease-in-out; }

/* ============================================
   CONTENT SECTIONS
   ============================================ */
.content-section {
    padding: 24px 12px;
    max-width: 800px;
    margin: 0 auto;
}
.content-section h1 { font-size: clamp(1.3rem, 5vw, 2rem); margin-bottom: 12px; }
.content-section h2 { font-size: clamp(1.1rem, 4vw, 1.5rem); margin: 20px 0 10px; }
.content-section h3 { font-size: clamp(1rem, 3.5vw, 1.1rem); margin: 14px 0 8px; }
.content-section p, .content-section li { margin-bottom: 10px; color: var(--text-color); font-size: clamp(0.85rem, 2.8vw, 1rem); }
.content-section a { color: var(--accent); text-decoration: underline; }
.content-section ul, .content-section ol { padding-left: 20px; }

.faq-item {
    margin-bottom: 16px;
    padding: 14px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}
.faq-item h3 { margin-top: 0; }

.example-row { display: flex; gap: 5px; margin: 10px 0; }
.example-row .tile {
    width: clamp(36px, 10vw, 44px);
    height: clamp(36px, 10vw, 44px);
    font-size: clamp(1rem, 4vw, 1.2rem);
    border: 2px solid var(--tile-border);
    display: flex; align-items: center; justify-content: center;
    font-weight: bold; color: var(--text-color);
    aspect-ratio: 1 / 1;
}
.tile.green { background: var(--green); color: white; }
.tile.yellow { background: var(--yellow); color: white; }
.tile.gray { background: var(--gray); color: white; }

.color-box {
    display: inline-block;
    width: 16px; height: 16px;
    border-radius: 3px;
    vertical-align: middle;
    margin-right: 6px;
}
.color-box.green { background: var(--green); }
.color-box.yellow { background: var(--yellow); }
.color-box.gray { background: var(--gray); }

.archive-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 20px;
}
.archive-item {
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
}
.archive-item a {
    display: flex;
    justify-content: space-between;
    padding: 14px 16px;
    text-decoration: none;
    color: var(--text-color);
    transition: background 0.2s;
    font-size: clamp(0.85rem, 2.8vw, 1rem);
}
.archive-item a:hover { background: var(--border-color); }
.archive-date { font-weight: 600; }
.archive-number { color: var(--text-secondary); font-size: 0.85rem; }

.contact-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-width: 500px;
    margin-top: 20px;
}
.contact-form label { font-weight: 600; font-size: 0.9rem; }
.contact-form input,
.contact-form textarea {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--bg-color);
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    width: 100%;
}
.contact-form input:focus,
.contact-form textarea:focus {
    outline: 2px solid var(--accent);
    border-color: transparent;
}

.success-message { background: #d4edda; color: #155724; padding: 12px; border-radius: 6px; margin: 12px 0; }
.error-message { background: #f8d7da; color: #721c24; padding: 12px; border-radius: 6px; margin: 12px 0; }

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: var(--bg-color);
    border-top: 1px solid var(--border-color);
    padding: 24px 0 12px;
    margin-top: auto;
}
.footer-inner {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}
.footer-col h3 { font-size: 1rem; margin-bottom: 10px; }
.footer-col p { font-size: 0.85rem; color: var(--text-secondary); }
.footer-col nav { display: flex; flex-direction: column; gap: 6px; }
.footer-col nav a {
    text-decoration: none;
    color: var(--text-secondary);
    font-size: 0.85rem;
}
.footer-col nav a:hover { color: var(--accent); }
.footer-bottom {
    border-top: 1px solid var(--border-color);
    padding-top: 12px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE BREAKPOINTS
   ============================================ */

/* Extra small phones (320px - 359px) */
@media (max-width: 359px) {
    .container { padding: 0 8px; }
    .game-board[data-length="5"] { width: min(96vw, 290px); }
    .key { height: 34px; font-size: 0.6rem; }
    .game-header h1 { font-size: 1.1rem; }
    .btn { min-width: 80px; padding: 8px 12px; font-size: 0.7rem; }
    .main-nav { gap: 6px; }
    .main-nav a { font-size: 0.65rem; }
    .logo { font-size: 0.95rem; }
    .ad-slot { min-height: 50px; margin: 10px auto; }
}

/* Small phones (360px - 479px) */
@media (min-width: 360px) and (max-width: 479px) {
    .game-board[data-length="5"] { width: min(94vw, 320px); }
    .key { height: 40px; }
}

/* Medium phones (480px - 767px) */
@media (min-width: 480px) and (max-width: 767px) {
    .game-board[data-length="5"] { width: min(80vw, 360px); }
}

/* Tablets (768px - 1023px) */
@media (min-width: 768px) {
    .container { padding: 0 24px; }
    .game-board[data-length="5"] { width: 380px; }
    .key { height: 48px; }
}

/* Desktops (1024px+) */
@media (min-width: 1024px) {
    .game-board[data-length="5"] { width: 360px; }
    .game-board[data-length="6"] { width: 400px; }
    .game-board[data-length="7"] { width: 440px; }
    .game-board[data-length="8"] { width: 480px; }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Print */
@media print {
    .site-header, .site-footer, .game-actions, .ad-slot, .main-nav, .game-controls-row {
        display: none !important;
    }
    .game-board { margin: 0 auto; }
    .tile { border: 1px solid #000; }
}