/* games/jigsaw/css/style.css */

/* ── Back link (setup screen) ── */
.setup-nav {
    margin-bottom: 12px;
}

.back-link {
    display: inline-block;
    color: #888;
    text-decoration: none;
    font-size: 0.85rem;
    padding: 6px 10px;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    min-height: 44px;
    line-height: 32px;
}

.back-link:hover {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

/* ── Piece counter (toolbar) ── */
.piece-count {
    font-family: 'Courier New', monospace;
    font-size: 0.95rem;
    color: #aaa;
    background: #000;
    padding: 5px 12px;
    border-radius: 4px;
    border: 1px solid #333;
    white-space: nowrap;
}

/* ── Win modal emoji ── */
.win-emoji {
    font-size: 3rem;
    margin-bottom: 8px;
}

.win-time {
    font-size: 1.2rem;
    color: #ccc;
    margin: 20px 0;
}

.win-time span {
    color: #0f0;
    font-weight: bold;
    font-family: 'Courier New', monospace;
}
body {
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #1a1a1a;
    color: #eee;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
}

.hidden {
    display: none !important;
}

#app {
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Setup Screen */
#setup-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle, #2a2a2a 0%, #111 100%);
}

.setup-container {
    background: rgba(50, 50, 50, 0.9);
    padding: 30px;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    max-width: 500px;
    width: 100%;
    backdrop-filter: blur(10px);
    border: 1px solid #444;
}

h1 {
    margin-top: 0;
    color: #fff;
    font-weight: 300;
    letter-spacing: 1px;
}

.form-group {
    margin-bottom: 20px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    color: #ccc;
}

.form-group input[type="file"],
.form-group input[type="number"],
.form-group select {
    width: 100%;
    padding: 10px;
    box-sizing: border-box;
    border-radius: 6px;
    border: 1px solid #555;
    background: #3a3a3a;
    color: white;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: #007bff;
}

.form-group input[type="range"] {
    width: 100%;
    cursor: pointer;
}

#image-preview {
    width: 100%;
    height: 200px;
    margin-top: 10px;
    border: 2px dashed #555;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #222;
    overflow: hidden;
    position: relative;
}

#image-preview img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

.btn {
    padding: 12px 24px;
    background: #007bff;
    color: white;
    border: none;
    cursor: pointer;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 600;
    transition: all 0.2s;
    width: 100%;
    margin-bottom: 10px;
}

.btn:hover:not(:disabled) {
    background: #0056b3;
    transform: translateY(-1px);
}

.btn:disabled {
    background: #444;
    color: #888;
    cursor: not-allowed;
    transform: none;
}

.btn-secondary {
    background: #555;
    width: auto;
    padding: 8px 16px;
    font-size: 0.9rem;
}

.btn-secondary:hover {
    background: #666;
}

/* Game Screen */
#game-screen {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    background: #111;
}

#toolbar {
    height: 60px;
    background: #222;
    display: flex;
    align-items: center;
    padding: 0 20px;
    justify-content: space-between;
    border-bottom: 1px solid #333;
    box-shadow: 0 2px 10px rgba(0,0,0,0.3);
    z-index: 10;
}

#timer {
    font-family: 'Courier New', monospace;
    font-size: 1.5rem;
    color: #0f0;
    text-shadow: 0 0 5px rgba(0, 255, 0, 0.5);
    background: #000;
    padding: 5px 15px;
    border-radius: 4px;
    border: 1px solid #333;
}

#puzzle-canvas {
    /* Remove fixed 100% size to respect JS calculated aspect ratio */
    margin: auto;
    background-image:
        linear-gradient(45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(-45deg, #1a1a1a 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #1a1a1a 75%),
        linear-gradient(-45deg, transparent 75%, #1a1a1a 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    background-color: #222;
    touch-action: none;
    cursor: grab;
    box-shadow: 0 0 20px rgba(0,0,0,0.5); /* Add shadow to frame the canvas */
}

#puzzle-canvas:active {
    cursor: grabbing;
}

/* Modals */
.modal-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: 1000;
    backdrop-filter: blur(5px);
}

.modal {
    background: #333;
    padding: 30px;
    border-radius: 12px;
    text-align: center;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
    border: 1px solid #555;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes popIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

.modal h2 {
    margin-top: 0;
    color: #fff;
    font-size: 2rem;
}

.modal p {
    font-size: 1.2rem;
    color: #ccc;
    margin: 20px 0;
}

#final-time {
    color: #0f0;
    font-weight: bold;
}

/* Camera Modal Styles */
.camera-modal-content {
    max-width: 600px; /* Wider for video */
    width: 95%;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.video-container {
    width: 100%;
    max-height: 60vh;
    background: #000;
    margin: 15px 0;
    border-radius: 8px;
    overflow: hidden;
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
}

#camera-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transform: scaleX(-1); /* Mirror the video */
}

.modal-actions {
    display: flex;
    width: 100%;
    gap: 10px;
    justify-content: center;
}

.modal-actions .btn {
    width: auto;
    flex: 1;
    margin-bottom: 0;
}

#camera-canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: none; /* Keep hidden */
}
