/* Color Palette - Shakespearean/Medieval Theme */
:root {
    --bg-gradient-1: #2a1f1a;
    --bg-gradient-2: #1a1410;
    --panel-bg: #f5e6c8;
    --panel-border: #6b4423;
    --tile-bg: #d4b896;
    --tile-border: #6b4423;
    --tile-selected: #c9a227;
    --gold: #c9a227;
    --red: #8b2500;
    --green: #2d5a27;
    --blue: #1e3a5f;
    --dark-text: #2c1810;
    --light-text: #f5e6c8;
    --shadow: rgba(0, 0, 0, 0.4);
    --heart-red: #8b0000;
    --heart-empty: #c9b896;
    --font-display: 'MedievalSharp', cursive;
    --font-body: 'IM Fell English', serif;
}

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

html, body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background:
        url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M54.627 0l.83.828-1.415 1.415L51.8 0h2.827zM5.373 0l-.83.828L5.96 2.243 8.2 0H5.374zM48.97 0l3.657 3.657-1.414 1.414L46.143 0h2.828zM11.03 0L7.372 3.657 8.787 5.07 13.857 0H11.03zm32.284 0L49.8 6.485 48.384 7.9l-7.9-7.9h2.83zM16.686 0L10.2 6.485 11.616 7.9l7.9-7.9h-2.83zM22.344 0L13.858 8.485 15.272 9.9l9.9-9.9h-2.828zM32 0l-3.486 3.485 1.414 1.415L32 2.828 34.07 4.9l1.415-1.415L32 0zm-7.657 0l-1.415 1.414 1.415 1.415L27.657 0h-3.314zM24.343 0L20.858 3.486l1.414 1.414L27.657 0h-3.314z' fill='%23000000' fill-opacity='0.03' fill-rule='evenodd'/%3E%3C/svg%3E"),
        linear-gradient(135deg, var(--bg-gradient-1) 0%, var(--bg-gradient-2) 100%);
    color: var(--dark-text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 15px;
    overflow-x: hidden;
}

/* Screen Management */
.screen {
    display: none;
    width: 100%;
    max-width: 1200px;
    max-height: 100vh;
    overflow: hidden;
}

.screen.active {
    display: flex;
    justify-content: center;
    align-items: center;
}

/* Title Screen */
.title-container {
    background: var(--panel-bg);
    border: 6px double var(--panel-border);
    border-radius: 8px;
    padding: 60px 40px;
    text-align: center;
    box-shadow: 0 10px 30px var(--shadow),
                inset 0 0 60px rgba(107, 68, 35, 0.1);
    max-width: 500px;
    width: 100%;
    position: relative;
}

.title-container::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 1px solid var(--panel-border);
    border-radius: 4px;
    pointer-events: none;
    opacity: 0.3;
}

.game-title {
    font-size: 3.5rem;
    color: var(--dark-text);
    margin-bottom: 10px;
    text-shadow: 2px 2px 0px rgba(201, 162, 39, 0.5),
                 4px 4px 8px rgba(0, 0, 0, 0.3);
    font-family: var(--font-display);
    letter-spacing: 2px;
}

.tagline {
    font-size: 1.3rem;
    color: var(--dark-text);
    font-style: italic;
    margin-bottom: 30px;
    font-family: var(--font-body);
    letter-spacing: 1px;
}

.mouse-hero {
    font-size: 6rem;
    margin: 30px 0;
    animation: float 3s ease-in-out infinite;
    filter: drop-shadow(5px 5px 5px rgba(0,0,0,0.3));
}

@keyframes float {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-15px) rotate(5deg); }
}

.daily-info {
    margin-top: 30px;
    font-size: 1.1rem;
    color: var(--dark-text);
    font-weight: normal;
    background: rgba(250, 246, 237, 0.7);
    padding: 10px 20px;
    border-radius: 4px;
    border: 2px solid var(--panel-border);
    font-family: var(--font-body);
}

/* Buttons - Shakespearean Style */
.btn-primary, .btn-secondary, .btn-action {
    font-family: var(--font-display);
    font-size: 1.2rem;
    padding: 15px 30px;
    border: 3px solid var(--panel-border);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.15s ease;
    font-weight: normal;
    margin: 5px;
    text-transform: none;
    box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 5px 10px rgba(0,0,0,0.3);
    letter-spacing: 1px;
    position: relative;
}

.btn-primary {
    background: linear-gradient(to bottom, #c9a227 0%, #a07d1c 100%);
    color: var(--dark-text);
    border-color: #6b4423;
}

.btn-primary:hover {
    background: linear-gradient(to bottom, #dab82e 0%, #c9a227 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 7px 15px rgba(0,0,0,0.4);
}

.btn-primary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.4), 0 2px 5px rgba(0,0,0,0.3);
}

.btn-secondary {
    background: linear-gradient(to bottom, #d4c4a8 0%, #c9b896 100%);
    color: var(--dark-text);
    border-color: #6b4423;
}

.btn-secondary:hover {
    background: linear-gradient(to bottom, #e5d6ba 0%, #d4c4a8 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 0 rgba(0,0,0,0.4), 0 7px 15px rgba(0,0,0,0.4);
}

.btn-secondary:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.4), 0 2px 5px rgba(0,0,0,0.3);
}

.btn-action {
    padding: 12px 25px;
    font-size: 1.1rem;
}

.btn-submit {
    background: linear-gradient(to bottom, #4a7c4b 0%, #2d5a27 100%);
    color: var(--light-text);
    border-color: #1a3518;
    font-size: 1.2rem;
    padding: 14px 35px;
}

.btn-submit:hover {
    background: linear-gradient(to bottom, #5a8c5b 0%, #4a7c4b 100%);
}

.btn-submit:disabled {
    background: #9e9e9e;
    cursor: not-allowed;
    opacity: 0.5;
    box-shadow: none;
}

.btn-clear {
    background: linear-gradient(to bottom, #b87333 0%, #8b5a2b 100%);
    color: var(--light-text);
    border-color: #5c3317;
}

.btn-clear:hover {
    background: linear-gradient(to bottom, #cd853f 0%, #b87333 100%);
}

.btn-scramble {
    background: linear-gradient(to bottom, #4a6fa5 0%, #1e3a5f 100%);
    color: var(--light-text);
    border-color: #152a42;
    position: relative;
}

.btn-scramble:hover {
    background: linear-gradient(to bottom, #5a7fb5 0%, #4a6fa5 100%);
}

.btn-scramble .tooltip {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #8b0000;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.3);
}

.btn-scramble .tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border-width: 6px;
    border-style: solid;
    border-color: #8b0000 transparent transparent transparent;
}

.btn-scramble:hover .tooltip {
    opacity: 1;
}

/* Battle Screen Layout */
.battle-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 100%;
    max-width: 900px;
    padding: 8px;
}

/* Combat Area - Top Section */
.combat-area {
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    background: var(--panel-bg);
    border: 4px double var(--panel-border);
    border-radius: 6px;
    padding: 10px;
    box-shadow: 0 3px 15px var(--shadow),
                inset 0 0 30px rgba(107, 68, 35, 0.08);
    min-height: 140px;
    flex-shrink: 0;
    position: relative;
}

/* Character Displays */
.character {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    gap: 5px;
    width: 160px;
    flex-shrink: 0;
    position: relative;
}

.character-visual {
    font-size: 3.5rem;
    filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
    transition: transform 0.15s ease;
}

/* Idle animation only when not attacking */
.character:not(.attacking) .character-visual {
    animation: idle 2s ease-in-out infinite;
}

@keyframes idle {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Player attack animation */
.player-character.attacking .character-visual {
    animation: playerAttack 0.5s ease;
}

@keyframes playerAttack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(80px) scale(1.2); }
    50% { transform: translateX(100px) scale(1.3) rotate(15deg); }
    70% { transform: translateX(80px) scale(1.1); }
    100% { transform: translateX(0) scale(1); }
}

/* Enemy attack animation */
.enemy-character.attacking .character-visual {
    animation: enemyAttack 0.5s ease;
}

@keyframes enemyAttack {
    0% { transform: translateX(0) scale(1); }
    30% { transform: translateX(-80px) scale(1.2); }
    50% { transform: translateX(-100px) scale(1.3) rotate(-15deg); }
    70% { transform: translateX(-80px) scale(1.1); }
    100% { transform: translateX(0) scale(1); }
}

/* Battle Arena - center area with word display */
.battle-arena {
    flex: 1;
    min-width: 150px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
}

.battle-arena .selected-tiles-display {
    display: flex;
    gap: 4px;
    align-items: center;
    justify-content: center;
    flex-wrap: nowrap;
    max-width: 100%;
    padding: 0 10px;
}

/* Flying tile animation */
.flying-tile {
    position: fixed;
    background: linear-gradient(135deg, var(--tile-bg) 0%, #b8936d 100%);
    border: 2px solid var(--tile-border);
    border-radius: 3px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    color: var(--dark-text);
    font-family: var(--font-display);
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
    pointer-events: none;
    z-index: 1000;
    transition: left 0.12s linear, top 0.12s linear;
}

.flying-tile.gem-green {
    background: linear-gradient(135deg, #4a7c4b 0%, #2d5a27 100%);
    color: var(--light-text);
    border-color: #1a3518;
}

.flying-tile.gem-red {
    background: linear-gradient(135deg, #a33327 0%, #8b2500 100%);
    color: var(--light-text);
    border-color: #5c1a00;
}

.flying-tile.gem-blue {
    background: linear-gradient(135deg, #4a6fa5 0%, #1e3a5f 100%);
    color: var(--light-text);
    border-color: #152a42;
}

.character-name {
    font-size: 1.2rem;
    font-weight: normal;
    color: var(--dark-text);
    text-align: center;
    text-transform: none;
    font-family: var(--font-display);
    letter-spacing: 1px;
}

/* Hearts Display */
.hearts-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 4px;
    max-width: 150px;
}

.heart {
    width: 20px;
    height: 18px;
    position: relative;
    filter: drop-shadow(1px 1px 2px rgba(0,0,0,0.3));
}

.heart::before,
.heart::after {
    content: '';
    position: absolute;
    top: 0;
    width: 12px;
    height: 18px;
    border-radius: 10px 10px 0 0;
    background: var(--heart-red);
}

.heart::before {
    left: 10px;
    transform: rotate(-45deg);
    transform-origin: 0 100%;
}

.heart::after {
    left: 0;
    transform: rotate(45deg);
    transform-origin: 100% 100%;
}

.heart.full::before,
.heart.full::after {
    background: var(--heart-red);
}

.heart.empty::before,
.heart.empty::after {
    background: var(--heart-empty);
    opacity: 0.5;
}

/* Partial hearts using gradient overlay */
.heart.half {
    position: relative;
}

.heart.half::before,
.heart.half::after {
    background: linear-gradient(90deg, var(--heart-red) 50%, var(--heart-empty) 50%);
}

.heart.quarter::before,
.heart.quarter::after {
    background: linear-gradient(90deg, var(--heart-red) 25%, var(--heart-empty) 25%);
}

.heart.three-quarter::before,
.heart.three-quarter::after {
    background: linear-gradient(90deg, var(--heart-red) 75%, var(--heart-empty) 75%);
}

.status-effects {
    min-height: 25px;
    font-size: 1.3rem;
    text-align: center;
}

/* Combat Field - Center */
.word-display-field {
    background: var(--panel-bg);
    border: 3px double var(--panel-border);
    border-radius: 6px;
    padding: 8px 15px;
    min-height: 60px;
    text-align: center;
    box-shadow: 0 2px 8px var(--shadow),
                inset 0 2px 6px rgba(107, 68, 35, 0.1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 8px;
}

.selected-tiles-display {
    display: flex;
    gap: 6px;
    min-height: 55px;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

.selected-tile-preview {
    width: var(--tile-size, 70px);
    height: var(--tile-size, 70px);
    min-width: 30px;
    min-height: 30px;
    flex-shrink: 1;
    background: linear-gradient(135deg, var(--tile-bg) 0%, #b8936d 100%);
    border: 2px solid var(--tile-border);
    border-radius: 3px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: clamp(1rem, 3vw, 1.8rem);
    font-weight: bold;
    color: var(--dark-text);
    font-family: var(--font-display);
    box-shadow: 0 3px 0 rgba(0,0,0,0.3);
    position: relative;
    transition: transform 0.1s ease, opacity 0.1s ease;
    aspect-ratio: 1;
}

.selected-tile-preview:hover {
    transform: scale(0.95);
    opacity: 0.8;
}

.selected-tile-preview.gem-green {
    background: linear-gradient(135deg, #4a7c4b 0%, #2d5a27 100%);
    color: var(--light-text);
    border-color: #1a3518;
    box-shadow: 0 2px 0 #1a3518, 0 0 15px rgba(45, 90, 39, 0.5);
}

.selected-tile-preview.gem-red {
    background: linear-gradient(135deg, #a33327 0%, #8b2500 100%);
    color: var(--light-text);
    border-color: #5c1a00;
    box-shadow: 0 2px 0 #5c1a00, 0 0 15px rgba(139, 37, 0, 0.5);
}

.selected-tile-preview.gem-blue {
    background: linear-gradient(135deg, #4a6fa5 0%, #1e3a5f 100%);
    color: var(--light-text);
    border-color: #152a42;
    box-shadow: 0 2px 0 #152a42, 0 0 15px rgba(30, 58, 95, 0.5);
}


.word-value {
    font-size: 1.1rem;
    color: var(--dark-text);
    font-weight: normal;
    font-family: var(--font-body);
}

.word-value.valid {
    color: var(--green);
}

.word-value.invalid {
    color: var(--red);
    animation: shake 0.3s ease;
}

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

/* Enemy Info Bar */
.enemy-info-bar {
    background: var(--panel-bg);
    border: 3px double var(--panel-border);
    border-radius: 4px;
    padding: 8px 20px;
    text-align: center;
}

.enemy-flavor {
    font-style: italic;
    color: var(--dark-text);
    margin: 0;
    font-size: 1rem;
    font-family: var(--font-body);
}

/* Letter Grid */
.grid-container {
    background: var(--panel-bg);
    border: 4px double var(--panel-border);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 3px 15px var(--shadow),
                inset 0 0 30px rgba(107, 68, 35, 0.08);
    flex-shrink: 0;
}

.letter-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 0;
    max-width: 340px;
    margin: 0 auto;
}

.tile {
    aspect-ratio: 1;
    background: linear-gradient(135deg, var(--tile-bg) 0%, #b8936d 100%);
    border: 2px solid var(--tile-border);
    border-radius: 3px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.15s ease;
    user-select: none;
    position: relative;
    box-shadow: 0 3px 0 rgba(0,0,0,0.3), inset 0 2px 0 rgba(255,255,255,0.3);
    color: var(--dark-text);
    font-family: var(--font-display);
}

.tile:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 12px var(--shadow), inset 0 2px 0 rgba(255,255,255,0.3);
}

.tile:active {
    transform: translateY(-1px);
}

.tile.selected {
    background: linear-gradient(135deg, var(--tile-selected) 0%, #a07d1c 100%);
    border-color: #6b4423;
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 15px rgba(201, 162, 39, 0.5), inset 0 2px 0 rgba(255,255,255,0.5);
}

.tile.gem-green {
    background: linear-gradient(135deg, #4a7c4b 0%, #2d5a27 100%);
    color: var(--light-text);
    border-color: #1a3518;
    box-shadow: 0 3px 0 #1a3518, 0 0 20px rgba(45, 90, 39, 0.5), inset 0 2px 0 rgba(255,255,255,0.3);
}

.tile.gem-red {
    background: linear-gradient(135deg, #a33327 0%, #8b2500 100%);
    color: var(--light-text);
    border-color: #5c1a00;
    box-shadow: 0 3px 0 #5c1a00, 0 0 20px rgba(139, 37, 0, 0.5), inset 0 2px 0 rgba(255,255,255,0.3);
}

.tile.gem-blue {
    background: linear-gradient(135deg, #4a6fa5 0%, #1e3a5f 100%);
    color: var(--light-text);
    border-color: #152a42;
    box-shadow: 0 3px 0 #152a42, 0 0 20px rgba(30, 58, 95, 0.5), inset 0 2px 0 rgba(255,255,255,0.3);
}

.tile-value {
    position: absolute;
    bottom: 3px;
    right: 6px;
    font-size: 0.75rem;
    opacity: 0.6;
    font-family: var(--font-body);
}

/* Tier indicator - small circle in lower right */
.tile-tier-indicator {
    position: absolute;
    bottom: 3px;
    right: 3px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    border: 1px solid rgba(0,0,0,0.3);
}

.tile-tier-indicator.tier-bronze {
    background: linear-gradient(135deg, #cd7f32 0%, #8b5a2b 100%);
}

.tile-tier-indicator.tier-silver {
    background: linear-gradient(135deg, #e8e8e8 0%, #a8a8a8 100%);
    box-shadow: 0 0 2px rgba(255, 255, 255, 0.5);
}

.tile-tier-indicator.tier-gold {
    background: linear-gradient(135deg, #ffd700 0%, #daa520 100%);
    box-shadow: 0 0 3px rgba(255, 215, 0, 0.6);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    justify-content: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 6px;
}

/* Battle Log */
.battle-log-mini {
    background: rgba(250, 246, 237, 0.9);
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    padding: 6px 10px;
    max-height: 50px;
    overflow-y: auto;
    font-size: 0.8rem;
    width: 100%;
    max-width: 500px;
    margin: 0 auto;
    font-family: var(--font-body);
}

.log-entry {
    padding: 3px 0;
    line-height: 1.4;
}

.log-entry.player-action {
    color: var(--green);
    font-weight: normal;
}

.log-entry.enemy-action {
    color: var(--red);
    font-weight: normal;
}

.log-entry.system {
    color: var(--dark-text);
    font-style: italic;
}

/* Results Screen */
.results-container {
    background: var(--panel-bg);
    border: 6px double var(--panel-border);
    border-radius: 8px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 30px var(--shadow),
                inset 0 0 60px rgba(107, 68, 35, 0.1);
    max-width: 600px;
    width: 100%;
}

#result-title {
    font-size: 2.8rem;
    color: var(--dark-text);
    margin-bottom: 30px;
    font-family: var(--font-display);
    text-shadow: 2px 2px 4px rgba(0,0,0,0.2);
    letter-spacing: 2px;
}

.result-streak {
    font-size: 1.3rem;
    color: #e67e22;
    margin-bottom: 15px;
    font-family: var(--font-display);
}

.result-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    padding: 15px;
    background: #faf6ed;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    box-shadow: 0 3px 0 rgba(0,0,0,0.2);
}

.stat-label {
    font-size: 0.95rem;
    color: var(--dark-text);
    opacity: 0.7;
    margin-bottom: 5px;
    font-weight: normal;
    font-family: var(--font-body);
}

.stat-value {
    font-size: 1.5rem;
    font-weight: normal;
    color: var(--dark-text);
    font-family: var(--font-display);
}

.share-container {
    margin: 30px 0;
}

.share-text {
    background: #faf6ed;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    padding: 20px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    text-align: left;
    white-space: pre-wrap;
    margin-bottom: 15px;
    box-shadow: inset 0 2px 5px rgba(0,0,0,0.1);
}

/* Stats Screen */
.stats-container {
    background: var(--panel-bg);
    border: 6px double var(--panel-border);
    border-radius: 8px;
    padding: 40px;
    box-shadow: 0 10px 30px var(--shadow),
                inset 0 0 60px rgba(107, 68, 35, 0.1);
    max-width: 600px;
    width: 100%;
}

.stats-container h2 {
    font-size: 2.2rem;
    color: var(--dark-text);
    margin-bottom: 30px;
    text-align: center;
    font-family: var(--font-display);
    letter-spacing: 2px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: #faf6ed;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 3px 0 rgba(0,0,0,0.2);
}

.stat-number {
    font-size: 2.5rem;
    font-weight: normal;
    color: var(--dark-text);
    margin-bottom: 10px;
    font-family: var(--font-display);
}

/* Best Words Section */
.best-words-section {
    margin-top: 20px;
    margin-bottom: 20px;
}

.best-words-section h3 {
    font-family: var(--font-display);
    font-size: 1.3rem;
    margin-bottom: 10px;
    color: var(--dark-text);
}

.best-words-list {
    background: #faf6ed;
    border: 2px solid var(--panel-border);
    border-radius: 4px;
    padding: 10px;
}

.best-word-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    font-family: var(--font-display);
    font-size: 1.1rem;
    border-bottom: 1px solid rgba(107, 68, 35, 0.2);
}

.best-word-item:last-child {
    border-bottom: none;
}

.best-word-damage {
    color: #c0392b;
    font-weight: bold;
}

.no-words {
    text-align: center;
    padding: 15px;
    color: var(--dark-text);
    opacity: 0.6;
    font-style: italic;
}

/* Tablet Responsive */
@media (max-width: 1024px) {
    .battle-container {
        max-width: 900px;
    }

    .letter-grid {
        max-width: 420px;
    }

    .tile {
        font-size: 2rem;
    }
}

/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        padding: 5px;
    }

    .battle-container {
        padding: 8px;
        gap: 8px;
        min-height: auto;
    }

    .combat-area {
        padding: 10px;
        min-height: 150px;
    }

    .character {
        width: 100px;
    }

    .character-visual {
        font-size: 3rem;
    }

    .character-name {
        font-size: 0.85rem;
    }

    .battle-arena {
        min-width: 80px;
    }

    @keyframes playerAttack {
        0% { transform: translateX(0) scale(1); }
        30% { transform: translateX(40px) scale(1.1); }
        50% { transform: translateX(50px) scale(1.2) rotate(10deg); }
        70% { transform: translateX(40px) scale(1.05); }
        100% { transform: translateX(0) scale(1); }
    }

    @keyframes enemyAttack {
        0% { transform: translateX(0) scale(1); }
        30% { transform: translateX(-40px) scale(1.1); }
        50% { transform: translateX(-50px) scale(1.2) rotate(-10deg); }
        70% { transform: translateX(-40px) scale(1.05); }
        100% { transform: translateX(0) scale(1); }
    }

    .word-display-field {
        padding: 10px 15px;
        min-height: 70px;
    }

    .selected-tiles-display {
        min-height: 45px;
        gap: 4px;
    }

    .battle-log-mini {
        font-size: 0.75rem;
        padding: 8px;
        max-height: 60px;
    }

    .enemy-info-bar {
        padding: 8px 15px;
    }

    .enemy-flavor {
        font-size: 0.85rem;
    }

    .game-title {
        font-size: 2.2rem;
    }

    .mouse-hero {
        font-size: 4rem;
    }

    .grid-container {
        padding: 12px;
    }

    .letter-grid {
        max-width: 100%;
        gap: 0;
    }

    .tile {
        font-size: 1.8rem;
    }

    .tile-value {
        font-size: 0.6rem;
    }

    .action-buttons {
        gap: 6px;
        margin-top: 8px;
    }

    .btn-action {
        font-size: 0.85rem;
        padding: 10px 18px;
        margin: 3px;
    }

    .result-stats {
        grid-template-columns: 1fr;
    }

    .stat-grid {
        grid-template-columns: 1fr;
    }

    .hearts-container {
        max-width: 100%;
        gap: 3px;
    }

    .heart {
        font-size: 1.1rem;
    }
}

/* Small Mobile */
@media (max-width: 480px) {
    .character-visual {
        font-size: 3rem;
    }

    .tile {
        font-size: 1.5rem;
    }

    .btn-action {
        font-size: 0.75rem;
        padding: 8px 15px;
    }
}

/* ============================================
   DAMAGE & HEAL NUMBERS
   ============================================ */
.damage-number {
    position: fixed;
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: normal;
    pointer-events: none;
    z-index: 1000;
    animation: damageFloat 1.5s ease-out forwards;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    transform: translateX(-50%);
}

.enemy-damage {
    color: #8b2500;
}

.player-damage {
    color: #8b0000;
}

.heal-number {
    position: fixed;
    font-family: var(--font-display);
    font-size: 2.2rem;
    font-weight: normal;
    color: #2d5a27;
    pointer-events: none;
    z-index: 1000;
    animation: healFloat 1.5s ease-out forwards;
    text-shadow: 2px 2px 0 rgba(0,0,0,0.5);
    transform: translateX(-50%);
}

@keyframes damageFloat {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(0.5);
    }
    20% {
        transform: translateX(-50%) translateY(-20px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-80px) scale(0.8);
    }
}

@keyframes healFloat {
    0% {
        opacity: 1;
        transform: translateX(-50%) translateY(0) scale(0.5);
    }
    20% {
        transform: translateX(-50%) translateY(-20px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateX(-50%) translateY(-80px) scale(0.8);
    }
}

/* ============================================
   SCREEN SHAKE
   ============================================ */
.combat-area.shake {
    animation: screenShake 0.3s ease;
}

@keyframes screenShake {
    0%, 100% { transform: translateX(0); }
    10% { transform: translateX(-8px) rotate(-1deg); }
    20% { transform: translateX(8px) rotate(1deg); }
    30% { transform: translateX(-6px) rotate(-0.5deg); }
    40% { transform: translateX(6px) rotate(0.5deg); }
    50% { transform: translateX(-4px); }
    60% { transform: translateX(4px); }
    70% { transform: translateX(-2px); }
    80% { transform: translateX(2px); }
    90% { transform: translateX(-1px); }
}

/* ============================================
   PLAYER HIT EFFECT
   ============================================ */
.player-character.hit {
    animation: playerHit 0.3s ease;
}

.player-character.hit .character-visual {
    filter: brightness(0.5) sepia(1) hue-rotate(-50deg) saturate(5);
}

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

.enemy-character.hit {
    animation: enemyHit 0.3s ease;
}

.enemy-character.hit .character-visual {
    filter: brightness(0.5) sepia(1) hue-rotate(-50deg) saturate(5);
}

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

/* ============================================
   LOCKED TILES
   ============================================ */
.tile.locked {
    background: linear-gradient(135deg, #7a7a7a 0%, #5a5a5a 100%) !important;
    border-color: #3d3d3d !important;
    color: #2a2a2a;
    cursor: not-allowed;
    box-shadow: 0 3px 0 #2a2a2a, inset 0 2px 0 rgba(255,255,255,0.2);
    position: relative;
}

.tile.locked::after {
    content: '🔒';
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.8rem;
}

.tile.locked:hover {
    transform: none;
    box-shadow: 0 3px 0 #2a2a2a, inset 0 2px 0 rgba(255,255,255,0.2);
}

/* ============================================
   POISONED TILES
   ============================================ */
.tile.poisoned {
    background: linear-gradient(135deg, #5a3d5c 0%, #3d2840 100%) !important;
    border-color: #2d1d30 !important;
    color: var(--light-text);
    box-shadow: 0 3px 0 #1a101c, 0 0 15px rgba(90, 61, 92, 0.6), inset 0 2px 0 rgba(255,255,255,0.3);
    animation: poisonPulse 2s ease-in-out infinite;
}

.tile.poisoned::after {
    content: '☠️';
    position: absolute;
    top: 2px;
    left: 2px;
    font-size: 0.7rem;
}

@keyframes poisonPulse {
    0%, 100% { box-shadow: 0 3px 0 #1a101c, 0 0 15px rgba(90, 61, 92, 0.6), inset 0 2px 0 rgba(255,255,255,0.3); }
    50% { box-shadow: 0 3px 0 #1a101c, 0 0 25px rgba(90, 61, 92, 0.9), inset 0 2px 0 rgba(255,255,255,0.3); }
}

/* ============================================
   IMPROVED ATTACK ANIMATION
   ============================================ */
@keyframes attack {
    0% { transform: scale(1) translateX(0); }
    25% { transform: scale(1.1) translateX(-20px); }
    50% { transform: scale(1.4) translateX(30px) rotate(-10deg); }
    75% { transform: scale(1.1) translateX(-10px); }
    100% { transform: scale(1) translateX(0); }
}

/* ============================================
   IMPROVED GEM GLOW EFFECTS
   ============================================ */
.tile.gem-green {
    animation: gemGlowGreen 2s ease-in-out infinite;
}

.tile.gem-red {
    animation: gemGlowRed 2s ease-in-out infinite;
}

.tile.gem-blue {
    animation: gemGlowBlue 2s ease-in-out infinite;
}

@keyframes gemGlowGreen {
    0%, 100% { box-shadow: 0 3px 0 #1a3518, 0 0 20px rgba(45, 90, 39, 0.5), inset 0 2px 0 rgba(255,255,255,0.3); }
    50% { box-shadow: 0 3px 0 #1a3518, 0 0 35px rgba(45, 90, 39, 0.8), inset 0 2px 0 rgba(255,255,255,0.5); }
}

@keyframes gemGlowRed {
    0%, 100% { box-shadow: 0 3px 0 #5c1a00, 0 0 20px rgba(139, 37, 0, 0.5), inset 0 2px 0 rgba(255,255,255,0.3); }
    50% { box-shadow: 0 3px 0 #5c1a00, 0 0 35px rgba(139, 37, 0, 0.8), inset 0 2px 0 rgba(255,255,255,0.5); }
}

@keyframes gemGlowBlue {
    0%, 100% { box-shadow: 0 3px 0 #152a42, 0 0 20px rgba(30, 58, 95, 0.5), inset 0 2px 0 rgba(255,255,255,0.3); }
    50% { box-shadow: 0 3px 0 #152a42, 0 0 35px rgba(30, 58, 95, 0.8), inset 0 2px 0 rgba(255,255,255,0.5); }
}

/* ============================================
   BUTTON ACTIVE STATES
   ============================================ */
.btn-submit:active:not(:disabled) {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

.btn-clear:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

.btn-scramble:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 rgba(0,0,0,0.3);
}

/* ============================================
   STATUS EFFECT INDICATORS
   ============================================ */
.status-effects {
    min-height: 25px;
    font-size: 1.3rem;
    text-align: center;
    display: flex;
    justify-content: center;
    gap: 5px;
}

/* ============================================
   WORD REACTION SPEECH BUBBLE
   ============================================ */
.speech-bubble {
    position: absolute;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    border-radius: 12px;
    padding: 8px 14px;
    font-family: var(--font-display);
    font-size: 1.2rem;
    color: var(--dark-text);
    white-space: nowrap;
    z-index: 100;
    bottom: 60px;
    left: calc(100% + 10px);
    transform-origin: left center;
    box-shadow: 0 3px 10px var(--shadow);
    animation: speechBubbleIn 0.25s ease forwards;
}

.speech-bubble.fade-out {
    animation: speechBubbleOut 0.3s ease forwards;
}

/* Tail pointing left toward the mouse */
.speech-bubble::after {
    content: '';
    position: absolute;
    left: -10px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 8px 10px 8px 0;
    border-style: solid;
    border-color: transparent var(--panel-border) transparent transparent;
}

.speech-bubble::before {
    content: '';
    position: absolute;
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
    border-width: 6px 8px 6px 0;
    border-style: solid;
    border-color: transparent var(--panel-bg) transparent transparent;
    z-index: 1;
}

@keyframes speechBubbleIn {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    70% {
        opacity: 1;
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes speechBubbleOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.8);
    }
}

/* ============================================
   HELP BUTTON & POPUP
   ============================================ */
.help-button {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--panel-bg);
    border: 2px solid var(--panel-border);
    color: var(--dark-text);
    font-family: var(--font-display);
    font-size: 1.3rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 2px 6px var(--shadow);
    transition: transform 0.15s ease, background 0.15s ease;
    z-index: 50;
}

.help-button:hover {
    transform: scale(1.1);
    background: var(--gold);
}

.help-popup {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

.help-popup.hidden {
    display: none;
}

.help-content {
    background: var(--panel-bg);
    border: 4px double var(--panel-border);
    border-radius: 10px;
    padding: 25px 30px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    font-family: var(--font-body);
    color: var(--dark-text);
}

.help-content h3 {
    font-family: var(--font-display);
    font-size: 1.6rem;
    margin-bottom: 12px;
    text-align: center;
}

.help-content h4 {
    font-family: var(--font-display);
    font-size: 1.2rem;
    margin-top: 16px;
    margin-bottom: 8px;
}

.help-content p {
    font-size: 1rem;
    line-height: 1.5;
    margin-bottom: 8px;
}

.help-close {
    position: absolute;
    top: 10px;
    right: 12px;
    background: none;
    border: none;
    font-size: 1.8rem;
    color: var(--dark-text);
    cursor: pointer;
    line-height: 1;
    opacity: 0.6;
    transition: opacity 0.15s ease;
}

.help-close:hover {
    opacity: 1;
}

.gem-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 10px 0;
}

.gem-item {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.gem-icon {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: inline-block;
}

.gem-green-icon {
    background: linear-gradient(135deg, #4a7c4b 0%, #2d5a27 100%);
    box-shadow: 0 0 8px rgba(45, 90, 39, 0.5);
}

.gem-red-icon {
    background: linear-gradient(135deg, #a33327 0%, #8b2500 100%);
    box-shadow: 0 0 8px rgba(139, 37, 0, 0.5);
}

.gem-blue-icon {
    background: linear-gradient(135deg, #4a6fa5 0%, #1e3a5f 100%);
    box-shadow: 0 0 8px rgba(30, 58, 95, 0.5);
}

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