* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Fredoka', 'Comic Sans MS', system-ui, -apple-system, sans-serif;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
}

body {
    background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    color: #f8fafc;
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    height: 100%;
    padding: 16px;
    position: absolute;
    top: 0;
    left: 0;
    overflow-y: auto;
}

.screen.active {
    display: flex;
}

/* Header */
.header {
    text-align: center;
    margin-top: 16px;
    margin-bottom: 24px;
}

.title {
    font-size: 2.8rem;
    color: #fbbf24;
    text-shadow: 2px 3px 0 #b45309, 0 0 20px rgba(251, 191, 36, 0.3);
}

.subtitle {
    font-size: 1.2rem;
    color: #94a3b8;
    margin-top: 4px;
}

/* Image Selector Grid */
.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 600px;
    margin-bottom: 24px;
}

.image-card {
    background: #334155;
    border: 4px solid #475569;
    border-radius: 20px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s;
}

.image-card:hover {
    transform: translateY(-4px);
    border-color: #38bdf8;
}

.image-card.selected {
    border-color: #fbbf24;
    background: #1e293b;
    box-shadow: 0 0 16px rgba(251, 191, 36, 0.5);
    transform: scale(1.04);
}

.image-card-canvas {
    width: 100px;
    height: 100px;
    border-radius: 12px;
    background: #0f172a;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.5);
}

.image-card-title {
    margin-top: 8px;
    font-size: 1rem;
    font-weight: bold;
    color: #f1f5f9;
}

/* Difficulty Selector */
.difficulty-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 28px;
}

.section-title {
    font-size: 1.1rem;
    color: #cbd5e1;
    margin-bottom: 10px;
    font-weight: bold;
}

.diff-container {
    display: flex;
    gap: 12px;
}

.diff-btn {
    background: #334155;
    border: 3px solid #475569;
    border-radius: 16px;
    padding: 10px 18px;
    color: #f8fafc;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: all 0.15s;
}

.diff-btn span {
    font-size: 1.3rem;
    font-weight: bold;
}

.diff-btn small {
    font-size: 0.85rem;
    color: #94a3b8;
}

.diff-btn.active {
    background: #0284c7;
    border-color: #38bdf8;
    box-shadow: 0 4px 12px rgba(56, 189, 248, 0.4);
}

/* Big Play Button */
.big-btn {
    background: linear-gradient(185deg, #22c55e 0%, #16a34a 100%);
    border: none;
    border-radius: 24px;
    padding: 18px 48px;
    color: #ffffff;
    font-size: 1.6rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 8px 0 #15803d, 0 12px 24px rgba(0,0,0,0.3);
    transition: transform 0.1s, box-shadow 0.1s;

    display: flex;
    align-items: center;
    gap: 8px;
}

.big-btn:hover {
    transform: translateY(-2px);
}

.big-btn:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #15803d;
}

/* Game Screen Layout */
#game-screen {
    padding: 12px;
    justify-content: flex-start;
}

.top-bar {
    width: 100%;
    max-width: 700px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(8px);
    padding: 8px 16px;
    border-radius: 20px;
    border: 2px solid #334155;
}

.hud-center {
    display: flex;
    gap: 12px;
}

.hud-badge {
    background: #0f172a;
    border: 2px solid #334155;
    padding: 6px 14px;
    border-radius: 14px;
    font-weight: bold;
    font-size: 1.05rem;
    color: #e2e8f0;
}

.hud-right {
    display: flex;
    gap: 8px;
}

.icon-btn {
    background: #334155;
    border: 2px solid #475569;
    border-radius: 14px;
    width: 46px;
    height: 46px;
    font-size: 1.4rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.15s;
}

.icon-btn:hover {
    background: #475569;
}

.icon-btn:active {
    transform: scale(0.92);
}

.hint-btn {
    background: #854d0e;
    border-color: #eab308;
    color: #fef08a;
}

/* Canvas Container */
#canvas-container {
    flex: 1;
    width: 100%;
    max-width: 700px;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
}

#puzzle-canvas {
    border-radius: 24px;
    background: #0f172a;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.6), 0 0 0 4px #334155;
    touch-action: none;
}

/* Victory Overlay */
.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(12px);
    z-index: 100;
    justify-content: center;
    align-items: center;
}

.overlay.active {
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.victory-card {
    background: #1e293b;
    border: 4px solid #fbbf24;
    border-radius: 32px;
    padding: 36px;
    text-align: center;
    box-shadow: 0 20px 50px rgba(0,0,0,0.6), 0 0 40px rgba(251, 191, 36, 0.4);
    max-width: 420px;
    width: 90%;
    display: flex;
    flex-direction: column;
    align-items: center;
    animation: popUp 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.victory-stars {
    font-size: 3rem;
    margin-bottom: 8px;
    animation: pulseStars 1.5s infinite alternate;
}

.victory-title {
    font-size: 2.2rem;
    color: #fbbf24;
    margin-bottom: 8px;
}

.victory-subtitle {
    font-size: 1.1rem;
    color: #cbd5e1;
    margin-bottom: 24px;
}

.victory-actions {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.big-btn.secondary {
    background: linear-gradient(185deg, #0284c7 0%, #0369a1 100%);
    box-shadow: 0 6px 0 #075985;
    padding: 14px 28px;
    font-size: 1.2rem;
}

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

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

@keyframes pulseStars {
    from { transform: scale(1); }
    to { transform: scale(1.1); }
}
