@import url('../styles.css');

.mobile-score {
    display: none;
    position: absolute;
    top: 5px;
    right: 5px;
    left: 5px;          /* stretch across so it never overflows */
    z-index: 1002;
    background: rgba(36,36,36,0.85);
    color: var(--text-muted);
    font-size: 0.8rem;
    padding: 0.5rem 1rem;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    font-weight: bold;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.responsive-layout {
    display: flex;
    flex-direction: row;
    justify-content: center;
    align-items: flex-start;
    gap: 2.5rem;
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
    box-sizing: border-box;
}
.game-side {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    position: relative;
}
.info-side {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
    min-width: 280px;
    max-width: 400px;
    background: rgba(36,36,36,0.85);
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.25);
    padding: 2rem;
}
.info-side h1 {
    font-size: 2.2rem;
    margin-bottom: 1rem;
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.info-side p { font-size: 1.1rem; margin-bottom: 1.5rem; color: var(--text-muted); }
.buttons-panel { display: flex; gap: 1rem; margin-top: 1.5rem; }
@media (max-width: 900px) {
    .responsive-layout { flex-direction: column; align-items: center; gap: 1.5rem; padding: 1rem 0.5rem; }
    .info-side { max-width: 100vw; width: 100%; margin-top: 0; align-items: center; text-align: center; }
    .info-side h1 { font-size: 1.7rem; }
    .game-side { width: 100%; justify-content: center; }
}
body { background: var(--grad-bg); color: #fff; min-height: 100vh; margin: 0; }

/* ===================== WORDLE GRID ===================== */
.wordle-grid {
    display: grid;
    grid-template-rows: repeat(6, 1fr);
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
    width: 320px;
    height: 380px;
}

/* Tile flip animation */
@keyframes flipTile {
    0%   { transform: rotateX(0deg); }
    49%  { transform: rotateX(90deg); }
    50%  { transform: rotateX(90deg); }
    100% { transform: rotateX(0deg); }
}

/* Shake animation for invalid word */
@keyframes shakeRow {
    0%,100% { transform: translateX(0); }
    15%  { transform: translateX(-6px); }
    30%  { transform: translateX(6px); }
    45%  { transform: translateX(-6px); }
    60%  { transform: translateX(6px); }
    75%  { transform: translateX(-4px); }
    90%  { transform: translateX(4px); }
}

/* Bounce animation for winning tiles */
@keyframes bounceTile {
    0%,100% { transform: translateY(0); }
    30%     { transform: translateY(-16px); }
    60%     { transform: translateY(-6px); }
    80%     { transform: translateY(-10px); }
}

/* Pop animation when typing a letter */
@keyframes popTile {
    0%   { transform: scale(1); }
    50%  { transform: scale(1.12); }
    100% { transform: scale(1); }
}

/* Pulsing border for current active tile */
@keyframes pulseBorder {
    0%,100% { border-color: #8fd3f4; box-shadow: 0 0 0 0 rgba(143,211,244,0); }
    50%     { border-color: #5ec2e6; box-shadow: 0 0 0 3px rgba(143,211,244,0.25); }
}

.wordle-tile {
    background: #333;
    border: 2px solid #555;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: bold;
    color: #fff;
    text-transform: uppercase;
    user-select: none;
    perspective: 400px;
    transform-style: preserve-3d;
    transition: background 0.1s, border-color 0.2s;
    backface-visibility: hidden;
}

.wordle-tile.filled {
    border-color: #8fd3f4;
    animation: pulseBorder 1.4s ease-in-out infinite;
}

.wordle-tile.pop {
    animation: popTile 0.1s ease-out forwards;
}

.wordle-tile.flip {
    animation: flipTile 0.5s ease-in-out forwards;
}

.wordle-tile.bounce {
    animation: bounceTile 0.5s ease-in-out forwards;
}

.wordle-tile.correct {
    background: #538d4e;
    border-color: #538d4e;
    animation: none;
}
.wordle-tile.present {
    background: #b59f3b;
    border-color: #b59f3b;
    animation: none;
}
.wordle-tile.absent {
    background: #3a3a3c;
    border-color: #3a3a3c;
    animation: none;
}

/* Row shake */
.wordle-row-wrap {
    display: contents;
}
.row-shake {
    animation: shakeRow 0.4s ease-in-out;
}

/* ===================== KEYBOARD ===================== */
.wordle-keyboard {
    margin-top: 12px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    /* 100% of parent = gameSide width, never exceeds viewport */
    width: 100%;
    max-width: 390px;
    padding: 0 5px;
    box-sizing: border-box;
}
.key-row {
    display: flex;
    gap: 4px;
    width: 100%;
}
.key-btn {
    flex: 1;
    min-width: 0;       /* allow shrinking below content size */
    height: 48px;
    padding: 0 2px;
    background: #818384;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    touch-action: manipulation;
    user-select: none;
    text-transform: uppercase;
    transition: background 0.3s, transform 0.15s, box-shadow 0.3s;
}
.key-btn.wide { flex: 1.55; font-size: 0.72rem; }
.key-btn:active { opacity: 0.8; transform: scale(0.93); }
.key-btn.correct {
    background: #538d4e;
    box-shadow: 0 0 8px rgba(83,141,78,0.5);
    transform: scale(1.05);
}
.key-btn.present { background: #b59f3b; }
.key-btn.absent  { background: #3a3a3c; }

/* ===================== STATUS MSG ===================== */
#statusMsg {
    font-size: 1rem;
    color: var(--text-muted);
    margin-top: 8px;
    min-height: 1.4em;
    text-align: center;
}

/* ===================== TOAST ===================== */
@keyframes slideDown {
    0%   { transform: translateY(-40px) translateX(-50%); opacity: 0; }
    15%  { transform: translateY(0) translateX(-50%); opacity: 1; }
    75%  { transform: translateY(0) translateX(-50%); opacity: 1; }
    100% { transform: translateY(-40px) translateX(-50%); opacity: 0; }
}

#wordleToast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(36,36,36,0.97);
    color: #8fd3f4;
    padding: 0.8rem 2rem;
    border-radius: 12px;
    font-size: 1.15rem;
    font-weight: bold;
    z-index: 2000;
    pointer-events: none;
    border: 1.5px solid #8fd3f4;
    box-shadow: 0 4px 24px rgba(0,0,0,0.35);
    animation: slideDown 3s ease forwards;
    white-space: nowrap;
}

/* ===================== STATS / DISTRIBUTION ===================== */
.stats-section {
    margin-top: 1.5rem;
    width: 100%;
}
.stats-section h3 {
    font-size: 1rem;
    color: var(--text-muted);
    margin: 0 0 0.7rem 0;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.dist-row {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 4px;
    font-size: 0.85rem;
}
.dist-label {
    width: 14px;
    text-align: right;
    color: #aaa;
    font-weight: bold;
    flex-shrink: 0;
}
.dist-bar-wrap {
    flex: 1;
    background: #333;
    border-radius: 3px;
    height: 18px;
    overflow: hidden;
}
.dist-bar {
    height: 100%;
    background: var(--grad-primary);
    border-radius: 3px;
    min-width: 4px;
    transition: width 0.5s ease;
    display: flex;
    align-items: center;
    padding-left: 6px;
    font-size: 0.78rem;
    font-weight: bold;
    color: #222;
    box-sizing: border-box;
}

/* Streak display */
.score-panel {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    font-size: 1rem;
    color: var(--text-muted);
    width: 100%;
}
.score-panel span {
    display: flex;
    align-items: center;
    gap: 0.4rem;
}
.streak-icon { font-size: 1.1em; }

/* ===================== BUTTONS ===================== */
#startBtn, #restartBtn {
    background: var(--grad-primary); color: #222; border: none; border-radius: 8px;
    padding: 0.9rem 2rem; font-size: 1.1rem; font-weight: bold; cursor: pointer;
    margin: 0 0.5rem; box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: background 0.2s, transform 0.2s;
}
#startBtn:hover, #restartBtn:hover { opacity: 0.9; transform: scale(1.05); }
#playAgainBtn {
    background: #8fd3f4; color: #222; border: none; border-radius: 8px;
    padding: 1rem 2.2rem; font-size: 1.2rem; font-weight: bold; cursor: pointer;
    transition: background 0.2s; margin-top: 1rem;
}
#playAgainBtn:hover { background: #5ec2e6; }
.popup {
    position: fixed; top: 0; left: 0; width: 100vw; height: 100vh;
    background: rgba(24,24,24,0.95); display: flex; align-items: center;
    justify-content: center; z-index: 1000;
}
.popup-content {
    background: #242424; padding: 2.5rem 3rem; border-radius: 20px;
    box-shadow: 0 4px 24px rgba(0,0,0,0.4); text-align: center;
    min-width: 280px; max-width: 90vw;
}
.popup-content h2 { margin-top: 0; color: #8fd3f4; font-size: 2rem; }
.popup-content p { font-size: 1.3rem; margin: 1rem 0; }
