@import url('https://fonts.googleapis.com/css2?family=VT323&display=swap');

/* CSS Variables */
:root {
    --mc-green: #4CAF50;
    --mc-green-light: #8BC34A;
    --mc-gold: #FFD700;
    --mc-red: #FF4444;
    --mc-cyan: #00E5FF;
    --mc-orange: #d97757;
    --mc-stone: #8b8b8b;
    --mc-stone-light: #c6c6c6;
    --mc-stone-dark: #555;
    --mc-bg: #1a1a2e;
    --mc-bg-light: #252545;
    --paper-bg: #f5f0e1;
    --paper-border: #5a4a3a;
    --paper-line: #333;
}

/* Reset & Base */
* { box-sizing: border-box; }

body {
    margin: 0;
    overflow: hidden;
    font-family: 'VT323', monospace;
    background-color: var(--mc-bg);
    color: #fff;
}

/* Layout */
#canvas-container {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: -1;
}

#ui-container {
    position: relative;
    width: 100%;
    height: 100vh;
    overflow-y: auto;
    z-index: 1;
}

/* Header */
header {
    position: relative;
    width: 100%;
    padding: 15px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
}

header > * { pointer-events: auto; }

.title-group {
    text-align: center;
    background: rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(4px);
    padding: 10px 30px;
    border-radius: 4px;
    border: 2px solid #1a1a1a;
}

#main-title {
    margin: 0;
    font-size: 2.5rem;
    text-shadow: 2px 2px 0 #000;
    color: #fff;
}

#sub-title {
    margin: 5px 0 0;
    font-size: 1.2rem;
    color: #ccc;
    text-shadow: 1px 1px 0 #000;
}

.back-home-btn {
    position: absolute;
    left: 20px; top: 20px;
    text-decoration: none;
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 15px;
    border: 2px solid #fff;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
    font-size: 1.2rem;
    box-shadow: 4px 4px 0 #000;
    font-family: 'VT323', monospace;
}

.back-home-btn:hover {
    transform: translate(-2px, -2px);
    box-shadow: 6px 6px 0 #000;
    background: rgba(0, 0, 0, 0.7);
}

.lang-switcher {
    position: absolute;
    right: 20px; top: 20px;
    display: flex;
    gap: 10px;
}

/* Minecraft Button Style */
.btn, .lang-btn {
    border: 2px solid #000;
    border-top-color: #fff;
    border-left-color: #fff;
    border-right-color: var(--mc-stone-dark);
    border-bottom-color: var(--mc-stone-dark);
    background-color: var(--mc-stone);
    color: #fff;
    padding: 8px 16px;
    font-size: 1.2rem;
    cursor: pointer;
    font-family: 'VT323', monospace;
    text-shadow: 1px 1px 0 #000;
    box-shadow: 2px 2px 0 #000;
    transition: transform 0.1s;
}

.btn:hover, .lang-btn:hover {
    background-color: #9b9b9b;
    transform: translate(-1px, -1px);
    box-shadow: 3px 3px 0 #000;
}

.btn:active, .lang-btn.active {
    background-color: #6b6b6b;
    border-top-color: var(--mc-stone-dark);
    border-left-color: var(--mc-stone-dark);
    border-right-color: #fff;
    border-bottom-color: #fff;
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
}

.lang-btn.active { background-color: #5b8c28; }

.btn.primary {
    background-color: #5b8c28;
    width: 100%;
    max-width: 300px;
    margin: 10px auto 0;
    display: block;
}

.btn.primary:hover { background-color: #6aa830; }

.btn.primary:disabled {
    background-color: var(--mc-stone-dark);
    color: #888;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* HUD Bar (Minecraft hotbar) */
#hud-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #333;
    border-bottom-color: #111;
    border-right-color: #111;
    padding: 8px 16px;
    margin: 0 auto 10px;
    max-width: 700px;
    width: 90%;
}

.hud-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1.1rem;
    white-space: nowrap;
}

.hud-icon { font-size: 1.3rem; }
.hud-label { color: #aaa; font-size: 0.9rem; }

/* XP Bar */
.xp-bar-container {
    width: 100px;
    height: 20px;
    background: #000;
    border: 2px solid #888;
    box-shadow: inset 2px 2px 0 #333;
    position: relative;
}

#xp-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(180deg, var(--mc-green), var(--mc-green-light));
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.3);
    transition: width 0.4s ease;
}

#xp-text { font-size: 0.9rem; color: #aaa; }

/* Streak Hearts */
.hud-streak { color: var(--mc-red); }
#streak-hearts { animation: heartbeat 1.5s ease-in-out infinite; }

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

/* Game Area */
#game-area {
    max-width: 700px;
    width: 90%;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    padding-bottom: 30px;
}

/* Calc Paper - parchment with pixel grid */
.calc-paper {
    background: var(--paper-bg);
    border: 3px solid var(--paper-border);
    box-shadow:
        inset 2px 2px 0 rgba(255,255,255,0.4),
        inset -2px -2px 0 rgba(0,0,0,0.15),
        4px 4px 0 rgba(0,0,0,0.5);
    padding: 24px 32px 28px;
    position: relative;
    min-width: 280px;
    width: auto;
    display: inline-block;
    background-image:
        linear-gradient(rgba(0,0,0,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.03) 1px, transparent 1px);
    background-size: 24px 24px;
}

#problem-display {
    display: flex;
    justify-content: center;
    width: 100%;
}

/* Calc Rows */
.calc-row {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0;
    min-height: 48px;
}

.operand-row { padding-right: 4px; }

.operator-row {
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 4px;
}

.operator-row .operand-digits {
    display: flex;
    justify-content: flex-end;
    flex: 1;
}

/* Operators */
.operator, .division-symbol, .equals-symbol {
    font-family: 'VT323', monospace;
    font-size: 36px;
    color: var(--mc-orange);
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.1);
    min-width: 36px;
    text-align: center;
}

/* Static digits */
.calc-digit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 48px; height: 56px;
    font-family: 'VT323', monospace;
    font-size: 36px;
    color: #333;
    text-align: center;
}

/* Calc Lines */
.calc-line {
    border-bottom: 3px solid var(--paper-line);
    margin: 4px 0;
    width: 100%;
}

.answer-row { margin-top: 4px; }

/* Partial Products */
#partial-products {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

#partial-products .calc-row { position: relative; }

/* Interactive Digit Cells */
.calc-cell {
    width: 48px; height: 56px;
    border: none;
    border-bottom: 3px dashed #999;
    background: transparent;
    font-family: 'VT323', monospace;
    font-size: 36px;
    text-align: center;
    color: #333;
    transition: all 0.2s;
    outline: none;
    cursor: pointer;
    padding: 0;
    line-height: 56px;
}

.calc-cell.active {
    border-bottom-color: var(--mc-cyan);
    box-shadow: 0 3px 0 var(--mc-cyan);
    animation: cellPulse 1s infinite;
}

.calc-cell.filled {
    color: var(--mc-bg);
    border-bottom-color: var(--mc-green);
}

.calc-cell.correct {
    color: var(--mc-green);
    border-bottom-color: var(--mc-green);
    border-bottom-style: solid;
}

.calc-cell.wrong {
    color: var(--mc-red);
    border-bottom-color: var(--mc-red);
    animation: cellShake 0.3s;
}

/* Carry Display */
.carry-row {
    display: flex;
    justify-content: flex-end;
    gap: 0;
    min-height: 20px;
    position: relative;
}

.carry-digit {
    width: 48px; height: 20px;
    font-family: 'VT323', monospace;
    font-size: 16px;
    color: var(--mc-orange);
    text-align: right;
    padding-right: 4px;
    animation: carryFadeIn 0.3s ease-out;
    line-height: 20px;
}

@keyframes carryFadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Division Layout (German Style) */
.division-paper { min-width: 320px; }

.division-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-family: 'VT323', monospace;
    font-size: 36px;
    color: #333;
    padding-bottom: 8px;
    border-bottom: 3px solid var(--paper-line);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

#dividend-display, #divisor-display { font-weight: bold; }
#quotient-cells { display: flex; gap: 0; }

#division-work {
    padding-left: 16px;
    font-family: 'VT323', monospace;
    font-size: 28px;
    color: #333;
}

.division-step { margin-bottom: 8px; position: relative; }

.division-step .subtract-value { color: #555; position: relative; }

.division-step .subtract-value::before {
    content: '-';
    position: absolute;
    left: -20px;
    color: var(--mc-orange);
}

.division-step .step-line {
    border-bottom: 2px solid #555;
    margin: 2px 0;
    width: 100%;
}

.division-step .step-result { font-weight: bold; }

#remainder-display {
    margin-top: 12px;
    font-size: 24px;
    color: var(--mc-orange);
    font-weight: bold;
    padding-top: 8px;
    border-top: 2px dashed #999;
}

/* Step Guide */
#step-guide {
    width: 100%;
    max-width: 500px;
    background: rgba(0, 0, 0, 0.5);
    border: 2px solid #444;
    padding: 12px 16px;
    text-align: center;
    font-size: 1.3rem;
    color: #eee;
    text-shadow: 1px 1px 0 #000;
}

#step-text { margin: 0; }
#step-text::after { content: '_'; animation: cursorBlink 1s step-end infinite; }

@keyframes cursorBlink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.carry-hint {
    display: inline-block;
    margin-top: 6px;
    background: rgba(217, 119, 87, 0.2);
    border: 1px solid var(--mc-orange);
    padding: 2px 10px;
    font-size: 1.1rem;
    color: var(--mc-orange);
}

/* Number Pad */
#numpad { width: 100%; max-width: 340px; }

.numpad-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    max-width: 300px;
    margin: 0 auto;
}

.num-btn {
    height: 60px;
    font-family: 'VT323', monospace;
    font-size: 28px;
    background: var(--mc-stone);
    color: white;
    border: none;
    border-top: 3px solid var(--mc-stone-light);
    border-left: 3px solid var(--mc-stone-light);
    border-right: 3px solid var(--mc-stone-dark);
    border-bottom: 3px solid var(--mc-stone-dark);
    box-shadow: 2px 2px 0 #000;
    cursor: pointer;
    text-shadow: 2px 2px 0 #000;
    transition: all 0.1s;
}

.num-btn:hover { background: #9b9b9b; }

.num-btn:active {
    transform: translate(1px, 1px);
    box-shadow: 1px 1px 0 #000;
    border-top-color: var(--mc-stone-dark);
    border-left-color: var(--mc-stone-dark);
    border-right-color: var(--mc-stone-light);
    border-bottom-color: var(--mc-stone-light);
}

.num-btn.hint-btn {
    background: var(--mc-orange);
    border-top-color: #e8a080;
    border-left-color: #e8a080;
    border-right-color: #a05530;
    border-bottom-color: #a05530;
}

.num-btn.clear-btn {
    background: #c0392b;
    border-top-color: #e74c3c;
    border-left-color: #e74c3c;
    border-right-color: #8e2a1e;
    border-bottom-color: #8e2a1e;
}

.action-buttons {
    margin-top: 12px;
    display: flex;
    justify-content: center;
}

/* Settings Panel */
#settings-panel {
    display: none;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    max-width: 90%;
    background-color: var(--mc-stone-light);
    border: 2px solid #000;
    box-shadow:
        inset 2px 2px 0 #fff,
        inset -2px -2px 0 var(--mc-stone-dark),
        4px 4px 0 #000;
    padding: 20px;
    z-index: 100;
    font-size: 1.1rem;
    color: #000;
}

#settings-panel.active { display: block; }

#settings-panel h3 {
    margin-top: 0;
    text-align: center;
    border-bottom: 2px solid #888;
    padding-bottom: 5px;
}

.setting-group { margin-bottom: 15px; }
.setting-group label { display: block; margin-bottom: 5px; font-weight: bold; }
.setting-options { display: flex; flex-direction: column; gap: 5px; }
.radio-wrapper { display: flex; align-items: center; gap: 8px; cursor: pointer; }
#level-name-display { font-size: 0.95rem; color: #555; margin-top: 4px; }

.close-panel-btn {
    position: absolute;
    top: 5px; right: 10px;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #333;
    font-family: 'VT323', monospace;
}

.close-panel-btn:hover { color: var(--mc-red); }

/* Feedback Overlay */
#feedback-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.6);
    z-index: 90;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

#feedback-content { text-align: center; animation: feedbackPop 0.4s ease-out; }
#feedback-icon { font-size: 4rem; margin-bottom: 10px; }
#feedback-message { font-size: 2.5rem; text-shadow: 3px 3px 0 #000; margin-bottom: 8px; }

#feedback-xp {
    font-size: 1.8rem;
    color: var(--mc-gold);
    text-shadow: 2px 2px 0 #000;
    animation: xpFloat 1.5s ease-out forwards;
}

@keyframes feedbackPop {
    from { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.1); }
    to { transform: scale(1); opacity: 1; }
}

/* Level-up Banner */
.level-up-banner {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    border: 4px solid var(--mc-gold);
    padding: 30px 50px;
    z-index: 100;
    text-align: center;
    animation: levelUp 0.5s ease-out;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.4);
}

.level-up-banner h2 {
    margin: 0;
    font-size: 2.5rem;
    color: var(--mc-gold);
    text-shadow: 3px 3px 0 #000;
}

.level-up-banner p { margin: 10px 0 0; font-size: 1.5rem; color: #eee; }

/* Animations */
@keyframes cellPulse {
    0%, 100% { box-shadow: 0 3px 0 var(--mc-cyan); }
    50% { box-shadow: 0 3px 0 var(--mc-cyan), 0 0 12px rgba(0, 229, 255, 0.3); }
}

@keyframes cellShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-6px); }
    40% { transform: translateX(6px); }
    60% { transform: translateX(-4px); }
    80% { transform: translateX(4px); }
}

@keyframes correctFlash {
    0% { background-color: transparent; }
    50% { background-color: rgba(76, 175, 80, 0.2); }
    100% { background-color: transparent; }
}

@keyframes levelUp {
    from { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
    to { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

@keyframes blockCollect {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(0.5) translateY(-40px); }
    100% { transform: scale(0) translateY(-80px); opacity: 0; }
}

@keyframes xpFloat {
    0% { transform: translateY(0); opacity: 1; }
    100% { transform: translateY(-30px); opacity: 0; }
}

/* Loading Screen */
#loading-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: #000;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-between;
    color: #fff;
    transition: opacity 0.5s ease-out;
    padding: 40px 0;
    font-family: 'VT323', monospace;
}

#loading-overlay.fade-out { opacity: 0; pointer-events: none; }

.mc-header { text-align: center; z-index: 1; margin-top: 40px; }

.mc-logo {
    font-size: 4rem;
    margin: 0;
    color: #fff;
    text-shadow: 4px 4px 0 #3f3f3f;
    letter-spacing: 2px;
    line-height: 1;
}

.mc-subtitle {
    font-size: 1.5rem;
    color: #ddd;
    text-shadow: 2px 2px 0 #3f3f3f;
    margin-top: 5px;
    letter-spacing: 1px;
}

.loading-container {
    width: 60%;
    max-width: 600px;
    text-align: center;
    z-index: 1;
    margin-bottom: 40px;
}

.loading-text { font-size: 1.8rem; margin-bottom: 5px; text-shadow: 2px 2px 0 #000; }

.loading-subtext {
    font-size: 1.2rem;
    color: #ccc;
    text-align: left;
    margin-bottom: 5px;
    text-shadow: 1px 1px 0 #000;
}

.loading-bar-bg {
    width: 100%;
    height: 20px;
    background: #555;
    border: 2px solid #888;
    box-shadow: inset 2px 2px 0 #333;
}

#loading-bar {
    width: 0%;
    height: 100%;
    background: #5b8c28;
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.3), inset 0 -2px 0 rgba(0,0,0,0.3);
    transition: width 0.2s linear;
}

.mc-tip-box {
    width: 70%;
    max-width: 800px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #fff;
    padding: 15px 20px;
    text-align: center;
    z-index: 1;
    margin-bottom: 20px;
}

#mc-tip-text { margin: 0; font-size: 1.2rem; color: #fff; text-shadow: 1px 1px 0 #000; }

/* Utility */
.hidden { display: none !important; }

/* Responsive - Tablet/Mobile */
@media (max-width: 600px) {
    header {
        position: relative;
        flex-direction: column;
        align-items: center;
        gap: 5px;
        padding: 5px;
        background: rgba(26, 26, 46, 0.95);
    }
    .title-group { order: 1; padding: 2px 10px; width: 100%; max-width: 300px; }
    #main-title { font-size: 1.4rem; }
    #sub-title { font-size: 0.7rem; margin: 0; }
    .back-home-btn { position: static; order: 2; padding: 4px 8px; font-size: 0.9rem; }
    .back-home-btn .text { display: none; }
    .lang-switcher { position: static; order: 3; gap: 5px; }
    .lang-btn { padding: 4px 8px; font-size: 0.9rem; }

    #hud-bar { flex-direction: column; align-items: stretch; gap: 6px; padding: 6px 10px; width: 95%; }
    .hud-item { justify-content: space-between; font-size: 1rem; }
    .xp-bar-container { flex: 1; }

    .calc-paper { padding: 16px 12px 20px; min-width: 240px; }
    .calc-digit, .calc-cell { width: 40px; height: 48px; font-size: 30px; line-height: 48px; }
    .operator, .division-symbol, .equals-symbol { font-size: 30px; min-width: 30px; }
    .carry-digit { width: 40px; font-size: 14px; }
    .division-header { font-size: 28px; }
    #division-work { font-size: 22px; }

    .numpad-grid { max-width: 100%; }
    .num-btn { height: 54px; font-size: 24px; }
    #step-guide { font-size: 1.1rem; padding: 8px 12px; }
    #settings-panel { width: 90%; max-width: 320px; }
    .level-up-banner { padding: 20px 30px; }
    .level-up-banner h2 { font-size: 2rem; }
    .level-up-banner p { font-size: 1.2rem; }
}

/* Extra small screens */
@media (max-width: 380px) {
    .calc-digit, .calc-cell { width: 32px; height: 40px; font-size: 24px; line-height: 40px; }
    .operator, .division-symbol, .equals-symbol { font-size: 24px; min-width: 24px; }
    .carry-digit { width: 32px; font-size: 12px; }
    .num-btn { height: 48px; font-size: 22px; }
    .calc-paper { padding: 12px 8px 16px; min-width: 200px; }
    .division-header { font-size: 24px; gap: 4px; }
    #division-work { font-size: 20px; padding-left: 10px; }
}

/* =========================================
   Additional States (JS-driven)
   ========================================= */

/* Settings panel open state */
#settings-panel.open {
    display: block;
}

/* Hint flash - briefly shows correct digit */
.calc-cell.hint-flash {
    color: var(--mc-gold) !important;
    background: rgba(255, 215, 0, 0.15);
    border-bottom-color: var(--mc-gold);
    animation: hintPulse 0.8s ease;
}

@keyframes hintPulse {
    0%, 100% { background: transparent; }
    50% { background: rgba(255, 215, 0, 0.25); }
}

/* Division step reveal animation */
.division-step.step-reveal {
    animation: stepReveal 0.4s ease-out;
}

@keyframes stepReveal {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Feedback overlay correct state */
#feedback-overlay.feedback-correct #feedback-icon {
    color: var(--mc-gold);
    font-size: 48px;
}

#feedback-overlay.feedback-correct #feedback-message {
    color: var(--mc-green);
}

#feedback-overlay.feedback-correct #feedback-xp {
    color: var(--mc-cyan);
}

/* Level-up banner fade out */
.level-up-banner.fade-out {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
    transition: all 0.5s ease;
}

/* Level-up sub text */
.level-up-title {
    font-size: 1.4rem;
    color: var(--mc-gold);
    text-transform: uppercase;
    margin-bottom: 8px;
}

.level-up-text {
    font-size: 2.2rem;
    color: #fff;
    text-shadow: 2px 2px 0 #000;
    margin-bottom: 4px;
}

.level-up-sub {
    font-size: 1.2rem;
    color: #ccc;
}

/* =========================================
   Student Registration Panel
   ========================================= */
#registration-panel {
    max-width: 400px;
    width: 90%;
    margin: 40px auto;
    background: rgba(0, 0, 0, 0.8);
    border: 3px solid var(--mc-gold);
    padding: 24px;
    text-align: center;
}

.reg-title {
    font-size: 2rem;
    color: var(--mc-gold);
    text-shadow: 2px 2px 0 #000;
    margin: 0 0 16px;
}

.reg-camera-preview {
    width: 200px;
    height: 150px;
    margin: 0 auto 16px;
    border: 3px solid var(--mc-cyan);
    background: #000;
    overflow: hidden;
}

.reg-camera-preview video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.reg-form-row {
    margin-bottom: 16px;
}

.name-input {
    width: 100%;
    max-width: 280px;
    padding: 10px 14px;
    font-family: 'VT323', monospace;
    font-size: 1.5rem;
    background: #333;
    color: #fff;
    border: 2px solid #666;
    border-top-color: #444;
    border-left-color: #444;
    border-right-color: #888;
    border-bottom-color: #888;
    text-align: center;
    outline: none;
}

.name-input:focus {
    border-color: var(--mc-cyan);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.3);
}

.start-btn {
    font-size: 1.4rem !important;
    padding: 12px 40px !important;
}

/* Player name tag in HUD */
.player-name-tag {
    color: var(--mc-gold);
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
}

/* Hide game elements when registration is showing */
#registration-panel ~ #hud-bar,
#registration-panel ~ #game-area,
#registration-panel ~ #ai-teacher-panel {
    display: none;
}

#registration-panel.hidden {
    display: none;
}

#registration-panel.hidden ~ #hud-bar,
#registration-panel.hidden ~ #game-area,
#registration-panel.hidden ~ #ai-teacher-panel {
    display: flex;
}

#registration-panel.hidden ~ #game-area {
    display: flex;
}

/* =========================================
   AI Teacher + Camera Panel
   ========================================= */
#ai-teacher-panel {
    max-width: 700px;
    width: 90%;
    margin: 10px auto 0;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid #444;
    border-radius: 4px;
    padding: 12px;
}

.teacher-camera-row {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 10px;
}

/* Camera PiP */
.camera-pip-wrapper {
    position: relative;
    width: 100px;
    height: 75px;
    border: 2px solid var(--mc-cyan);
    background: #000;
    overflow: hidden;
    flex-shrink: 0;
}

#camera-pip {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1);
}

.camera-pip-label {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.7);
    font-size: 0.7rem;
    text-align: center;
    padding: 1px;
    color: var(--mc-cyan);
}

.camera-toggle-btn {
    position: absolute;
    top: 2px;
    right: 2px;
    background: rgba(0,0,0,0.5);
    border: none;
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    padding: 2px 4px;
    line-height: 1;
    border-radius: 2px;
}
.camera-toggle-btn:hover { background: rgba(0,0,0,0.8); }

/* Teacher Avatar - CSS Minecraft Villager */
.teacher-avatar-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    flex-shrink: 0;
}

.teacher-avatar {
    width: 56px;
    height: 56px;
    background: #c4a07a;
    border: 2px solid #8B6914;
    position: relative;
    image-rendering: pixelated;
}

.villager-head {
    width: 100%;
    height: 100%;
    position: relative;
}

.villager-eyes {
    position: absolute;
    top: 16px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
}

.eye {
    display: block;
    width: 8px;
    height: 8px;
    background: #fff;
    position: relative;
}

.eye::after {
    content: '';
    position: absolute;
    width: 4px;
    height: 4px;
    background: #333;
    bottom: 0;
    right: 0;
}

.villager-nose {
    position: absolute;
    top: 24px;
    left: 50%;
    transform: translateX(-50%);
    width: 12px;
    height: 16px;
    background: #a08060;
    border: 1px solid #7a6040;
}

.villager-mouth {
    position: absolute;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    width: 8px;
    height: 3px;
    background: #6a4a30;
    transition: all 0.15s;
}

.villager-mouth.talking {
    height: 8px;
    width: 10px;
    border-radius: 0 0 3px 3px;
    background: #5a3a20;
}

.teacher-name {
    font-size: 0.8rem;
    color: var(--mc-gold);
    text-shadow: 1px 1px 0 #000;
}

/* Speech Bubble */
.speech-bubble {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid #666;
    border-left: 3px solid var(--mc-gold);
    padding: 8px 12px;
    margin-bottom: 8px;
    min-height: 40px;
    position: relative;
}

#speech-text {
    margin: 0;
    font-size: 1.1rem;
    color: #eee;
    line-height: 1.4;
}

.speech-bubble.ai-thinking #speech-text {
    color: #888;
    font-style: italic;
}

.speech-bubble.ai-thinking::after {
    content: '...';
    animation: dots 1.5s steps(3) infinite;
}

@keyframes dots {
    0% { content: '.'; }
    33% { content: '..'; }
    66% { content: '...'; }
}

/* Voice Controls */
.voice-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.mic-btn {
    flex: 1;
    background: var(--mc-orange) !important;
    text-align: center;
}

.mic-btn.listening {
    background: var(--mc-red) !important;
    animation: micPulse 1s ease-in-out infinite;
}

@keyframes micPulse {
    0%, 100% { box-shadow: 2px 2px 0 #000; }
    50% { box-shadow: 2px 2px 0 #000, 0 0 12px rgba(255, 68, 68, 0.6); }
}

.mute-btn {
    width: 44px;
    text-align: center;
    padding: 8px !important;
}

.mute-btn.muted {
    opacity: 0.5;
    text-decoration: line-through;
}

/* Responsive adjustments for teacher panel */
@media (max-width: 600px) {
    .teacher-camera-row { gap: 10px; }
    .camera-pip-wrapper { width: 80px; height: 60px; }
    .teacher-avatar { width: 44px; height: 44px; }
    .villager-eyes { top: 12px; left: 8px; right: 8px; }
    .eye { width: 6px; height: 6px; }
    .eye::after { width: 3px; height: 3px; }
    .villager-nose { top: 18px; width: 10px; height: 12px; }
    .villager-mouth { bottom: 4px; }
    #speech-text { font-size: 1rem; }
}

@media (max-width: 380px) {
    .camera-pip-wrapper { width: 64px; height: 48px; }
    .teacher-avatar { width: 36px; height: 36px; }
}

/* =========================================
   Boss Battle
   ========================================= */
#boss-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.85);
    display: flex; align-items: center; justify-content: center;
    z-index: 800;
    animation: bossFadeIn 0.5s;
}
@keyframes bossFadeIn { from { opacity: 0; } to { opacity: 1; } }

.boss-container {
    text-align: center;
    animation: bossEntrance 0.6s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes bossEntrance { 0% { transform: scale(0); } 70% { transform: scale(1.2); } 100% { transform: scale(1); } }

.boss-name {
    font-family: 'VT323', monospace;
    font-size: 2.5rem;
    color: #ff4444;
    text-shadow: 0 0 20px rgba(255,0,0,0.6), 2px 2px 0 #000;
    margin-bottom: 20px;
    letter-spacing: 3px;
}

.boss-sprite {
    width: 120px; height: 120px;
    margin: 0 auto 20px;
    image-rendering: pixelated;
    position: relative;
}

/* Zombie boss */
.boss-sprite.zombie {
    background: #4a7a3f;
    box-shadow:
        inset 20px 20px 0 #3d6634,
        inset -20px -20px 0 #5a8a4f;
}
.boss-sprite.zombie::before {
    content: '';
    position: absolute;
    top: 30px; left: 25px;
    width: 20px; height: 20px;
    background: #1a1a1a;
    box-shadow: 50px 0 0 #1a1a1a; /* two eyes */
}
.boss-sprite.zombie::after {
    content: '';
    position: absolute;
    top: 65px; left: 35px;
    width: 50px; height: 15px;
    background: #2a2a2a;
}

/* Skeleton boss */
.boss-sprite.skeleton {
    background: #d4cfc7;
    box-shadow: inset 10px 10px 0 #c4bfb7, inset -10px -10px 0 #e4dfd7;
}
.boss-sprite.skeleton::before {
    content: '';
    position: absolute;
    top: 30px; left: 20px;
    width: 25px; height: 25px;
    background: #0a0a0a;
    box-shadow: 55px 0 0 #0a0a0a;
}
.boss-sprite.skeleton::after {
    content: '';
    position: absolute;
    top: 70px; left: 30px;
    width: 60px; height: 10px;
    background: #2a2a2a;
    box-shadow:
        10px -10px 0 #2a2a2a,
        20px -10px 0 #2a2a2a,
        30px -10px 0 #2a2a2a,
        40px -10px 0 #2a2a2a;
}

/* Enderman boss */
.boss-sprite.enderman {
    background: #1a0a2e;
    box-shadow: inset 10px 10px 0 #2d1b50;
}
.boss-sprite.enderman::before {
    content: '';
    position: absolute;
    top: 35px; left: 15px;
    width: 30px; height: 10px;
    background: #ff00ff;
    box-shadow: 45px 0 0 #ff00ff;
}

/* Wither boss */
.boss-sprite.wither {
    background: #2a2a2a;
    box-shadow: inset 10px 10px 0 #3a3a3a;
}
.boss-sprite.wither::before {
    content: '';
    position: absolute;
    top: 25px; left: 10px;
    width: 25px; height: 25px;
    background: #d4d4d4;
    box-shadow: 35px 0 0 #d4d4d4, 70px 0 0 #d4d4d4; /* three heads */
}
.boss-sprite.wither::after {
    content: '';
    position: absolute;
    top: 55px; left: 20px;
    width: 80px; height: 20px;
    background: #3a3a3a;
}

.boss-hp-bar {
    width: 250px; height: 24px;
    background: #333;
    margin: 0 auto;
    position: relative;
    border: 3px solid #555;
}
.boss-hp-fill {
    height: 100%;
    background: linear-gradient(180deg, #ff4444, #cc2222);
    transition: width 0.3s ease;
    width: 100%;
}
.boss-hp-text {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    color: white;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    text-shadow: 1px 1px 0 #000;
}

.boss-hit { animation: bossShake 0.3s; }
@keyframes bossShake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-10px) rotate(-3deg); }
    40% { transform: translateX(10px) rotate(3deg); }
    60% { transform: translateX(-5px); }
    80% { transform: translateX(5px); }
}
.boss-attack-flash {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 0, 0, 0);
    pointer-events: none;
    z-index: 801;
}
.boss-attack-flash.flash {
    animation: bossAttackFlash 0.2s;
}
@keyframes bossAttackFlash {
    0% { background: rgba(255, 0, 0, 0); }
    50% { background: rgba(255, 0, 0, 0.4); }
    100% { background: rgba(255, 0, 0, 0); }
}

.boss-attack-flash {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(255, 0, 0, 0);
    pointer-events: none;
    z-index: 801;
}
.boss-attack-flash.flash {
    animation: bossAttackFlash 0.2s;
}
@keyframes bossAttackFlash {
    0% { background: rgba(255, 0, 0, 0); }
    50% { background: rgba(255, 0, 0, 0.4); }
    100% { background: rgba(255, 0, 0, 0); }
}

.boss-defeat { animation: bossExplode 0.8s forwards; }
@keyframes bossExplode {
    0% { transform: scale(1); opacity: 1; }
    30% { transform: scale(1.3); }
    100% { transform: scale(0) rotate(720deg); opacity: 0; }
}

/* =========================================
   Achievement Toast
   ========================================= */
.achievement-toast {
    position: fixed;
    bottom: 30px; right: 30px;
    background: linear-gradient(135deg, #2a2a2a, #1a1a1a);
    border: 3px solid #ffd700;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 15px;
    z-index: 900;
    min-width: 280px;
    animation: achSlideIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.3);
}
.achievement-toast.hiding {
    animation: achSlideOut 0.5s forwards;
}
@keyframes achSlideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes achSlideOut {
    to { transform: translateX(120%); opacity: 0; }
}
.ach-icon { font-size: 2.5rem; }
.ach-label {
    font-family: 'VT323', monospace;
    font-size: 0.75rem;
    color: #ffd700;
    text-transform: uppercase;
    letter-spacing: 2px;
}
.ach-name {
    font-family: 'VT323', monospace;
    font-size: 1.3rem;
    color: #fff;
    margin: 2px 0;
}
.ach-desc {
    font-size: 0.8rem;
    color: #aaa;
}

/* =========================================
   Timer Bar
   ========================================= */
#timer-bar {
    width: 100%;
    height: 10px;
    background: #333;
    position: relative;
    margin-bottom: 10px;
    border: 2px solid #555;
}
.timer-fill {
    height: 100%;
    background: #4ade80;
    transition: width 0.1s linear, background-color 0.5s;
    width: 100%;
}
.timer-fill.warning { background: #fbbf24; }
.timer-fill.danger { background: #ef4444; animation: timerPulse 0.5s infinite; }
@keyframes timerPulse { 50% { opacity: 0.5; } }
.timer-text {
    position: absolute;
    right: 10px; top: -22px;
    font-family: 'VT323', monospace;
    font-size: 1.4rem;
    color: #fff;
    text-shadow: 1px 1px 0 #000;
}
.timer-score {
    position: absolute;
    left: 10px; top: -22px;
    font-family: 'VT323', monospace;
    font-size: 1rem;
    color: #ffd700;
}

/* =========================================
   Building Display
   ========================================= */
.building-display {
    position: fixed;
    bottom: 10px; left: 10px;
    z-index: 50;
    pointer-events: none;
}
.building-grid {
    display: grid;
    grid-template-columns: repeat(8, 18px);
    direction: ltr;
    align-content: end;
    min-height: 50px;
    max-height: 200px;
}
.building-block {
    width: 18px; height: 18px;
    image-rendering: pixelated;
    animation: blockDrop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
@keyframes blockDrop {
    from { transform: translateY(-30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}
.building-block.oak { background: #8B6914; border: 1px solid #6B4E0B; }
.building-block.cobble { background: #808080; border: 1px solid #666; }
.building-block.iron { background: #d4af87; border: 1px solid #b89070; }
.building-block.gold { background: #fcee4b; border: 1px solid #d4c226; }
.building-block.diamond { background: #64d4d2; border: 1px solid #2EB8B6; }
.building-block.netherite { background: #4a2c78; border: 1px solid #2d1b50; }
.building-block.emerald { background: #2d8a4e; border: 1px solid #1a6a3e; }
.building-label {
    font-family: 'VT323', monospace;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    text-align: center;
    margin-top: 4px;
}

/* =========================================
   Mining Crack Overlay
   ========================================= */
.mining-crack {
    position: absolute; top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    z-index: 5;
    transition: opacity 0.2s;
}
.mining-crack.stage-1 { background: radial-gradient(circle at 50% 50%, rgba(0,0,0,0.05) 0%, transparent 60%); }
.mining-crack.stage-2 {
    background:
        linear-gradient(45deg, transparent 40%, rgba(0,0,0,0.08) 40%, rgba(0,0,0,0.08) 41%, transparent 41%),
        linear-gradient(-30deg, transparent 45%, rgba(0,0,0,0.08) 45%, rgba(0,0,0,0.08) 46%, transparent 46%);
}
.mining-crack.stage-3 {
    background:
        linear-gradient(45deg, transparent 35%, rgba(0,0,0,0.1) 35%, rgba(0,0,0,0.1) 36%, transparent 36%),
        linear-gradient(-60deg, transparent 40%, rgba(0,0,0,0.1) 40%, rgba(0,0,0,0.1) 41%, transparent 41%),
        linear-gradient(20deg, transparent 50%, rgba(0,0,0,0.08) 50%, rgba(0,0,0,0.08) 51%, transparent 51%);
}
.mining-crack.stage-4 {
    background:
        linear-gradient(45deg, transparent 30%, rgba(0,0,0,0.12) 30%, rgba(0,0,0,0.12) 31%, transparent 31%),
        linear-gradient(-60deg, transparent 35%, rgba(0,0,0,0.12) 35%, rgba(0,0,0,0.12) 36%, transparent 36%),
        linear-gradient(20deg, transparent 45%, rgba(0,0,0,0.1) 45%, rgba(0,0,0,0.1) 46%, transparent 46%),
        linear-gradient(-20deg, transparent 55%, rgba(0,0,0,0.1) 55%, rgba(0,0,0,0.1) 56%, transparent 56%);
}
.mining-crack.stage-5 {
    background:
        linear-gradient(45deg, transparent 25%, rgba(0,0,0,0.15) 25%, rgba(0,0,0,0.15) 27%, transparent 27%),
        linear-gradient(-60deg, transparent 30%, rgba(0,0,0,0.15) 30%, rgba(0,0,0,0.15) 32%, transparent 32%),
        linear-gradient(20deg, transparent 40%, rgba(0,0,0,0.12) 40%, rgba(0,0,0,0.12) 42%, transparent 42%),
        linear-gradient(-20deg, transparent 50%, rgba(0,0,0,0.12) 50%, rgba(0,0,0,0.12) 52%, transparent 52%),
        linear-gradient(80deg, transparent 60%, rgba(0,0,0,0.1) 60%, rgba(0,0,0,0.1) 62%, transparent 62%);
    animation: crackPulse 0.3s;
}
@keyframes crackPulse { 50% { opacity: 0.7; } }

/* =========================================
   Shop Panel
   ========================================= */
#shop-panel {
    position: fixed; top: 0; right: -100%; width: 320px; height: 100%;
    background: linear-gradient(180deg, #3a3a3a, #2a2a2a);
    border-left: 4px solid #555;
    z-index: 700;
    padding: 20px;
    transition: right 0.3s ease;
    overflow-y: auto;
    box-shadow: -5px 0 30px rgba(0,0,0,0.5);
}
#shop-panel.open { right: 0; }
#shop-panel h3 {
    font-family: 'VT323', monospace;
    font-size: 2rem;
    color: #ffd700;
    text-align: center;
    margin-bottom: 15px;
}
.shop-balance {
    text-align: center;
    font-size: 1.8rem;
    color: #ffd700;
    margin-bottom: 20px;
    font-family: 'VT323', monospace;
}
.shop-items {
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.shop-item {
    background: rgba(0,0,0,0.4);
    border: 2px solid #555;
    padding: 12px;
    display: grid;
    grid-template-columns: 50px 1fr auto;
    grid-template-rows: auto auto;
    gap: 4px 10px;
    align-items: center;
    transition: border-color 0.2s;
}
.shop-item:hover { border-color: #ffd700; }
.item-icon {
    font-size: 2rem;
    grid-row: 1 / 3;
    text-align: center;
}
.item-name {
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    color: #fff;
}
.item-desc {
    font-size: 0.75rem;
    color: #888;
    grid-column: 2;
}
.item-price {
    font-family: 'VT323', monospace;
    font-size: 1rem;
    color: #ffd700;
    grid-row: 1;
}
.shop-buy-btn {
    grid-row: 2;
    grid-column: 3;
    background: #4ade80 !important;
    color: #000 !important;
    border-color: #22c55e !important;
    padding: 4px 12px !important;
    font-size: 0.85rem !important;
}
.shop-buy-btn:hover { background: #22c55e !important; }
.shop-buy-btn.disabled {
    background: #555 !important;
    border-color: #444 !important;
    color: #888 !important;
    cursor: not-allowed;
}

/* =========================================
   HUD Additions
   ========================================= */
.hud-coins {
    color: #ffd700;
    font-family: 'VT323', monospace;
}
.coin-icon { text-shadow: 0 0 5px rgba(255, 215, 0, 0.5); }
.coin-collect-float {
    position: fixed;
    color: #ffd700;
    font-family: 'VT323', monospace;
    font-size: 1.2rem;
    pointer-events: none;
    animation: coinFloat 1s forwards;
    z-index: 999;
}
@keyframes coinFloat {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(-40px); opacity: 0; }
}
.hud-inventory {
    display: flex;
    gap: 4px;
}
.inventory-item {
    width: 32px; height: 32px;
    background: rgba(0,0,0,0.5);
    border: 2px solid #555;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    position: relative;
    cursor: pointer;
}
.inventory-item:hover { border-color: #ffd700; }
.inventory-item .item-count {
    position: absolute;
    bottom: -2px; right: -2px;
    background: #ef4444;
    color: white;
    font-size: 0.6rem;
    min-width: 14px;
    height: 14px;
    border-radius: 7px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'VT323', monospace;
}

/* =========================================
   Responsive Additions
   ========================================= */
@media (max-width: 600px) {
    .achievement-toast {
        bottom: 10px; right: 10px; left: 10px;
        min-width: auto;
    }
    .building-display { display: none; }
    #shop-panel { width: 100%; }
    .boss-sprite { width: 80px; height: 80px; }
    .boss-name { font-size: 1.8rem; }
}
