/* START: Minigame Styles */

/* ── Overlay ── */
#mg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.97);
    z-index: 9000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    overflow: hidden;
    padding-bottom: 90px;
    box-sizing: border-box;
}

@media (max-width: 768px) {
    #mg-overlay { padding-bottom: 62px; }
}

/* ── Header ── */
.mg-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 5px 12px 3px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.mg-title {
    font-size: 15px;
    font-weight: bold;
    color: var(--primary);
}

.mg-timer-label {
    font-size: 13px;
    color: #aaa;
    min-width: 28px;
    text-align: right;
}

.mg-total-counter {
    font-size: 12px;
    font-weight: bold;
    color: var(--primary);
    min-width: 60px;
    text-align: right;
    opacity: 0.85;
}

/* ── Abort button ── */
.mg-abort-btn {
    background: rgba(180, 40, 40, 0.2);
    border: 1px solid #883030;
    border-radius: 6px;
    color: #cc5555;
    font-size: 12px;
    padding: 4px 12px;
    cursor: pointer;
    transition: background 0.15s;
}
.mg-abort-btn:hover { background: rgba(180, 40, 40, 0.4); }

/* ── Timer bar ── */
.mg-timer-wrap {
    width: 100%;
    padding: 0 12px 4px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.mg-timer-bar-bg {
    width: 100%;
    height: 7px;
    background: rgba(255, 255, 255, 0.12);
    border-radius: 4px;
    overflow: hidden;
}

.mg-timer-bar {
    height: 100%;
    width: 100%;
    background: var(--primary);
    border-radius: 4px;
    transition: width 1s linear, background 0.4s;
}

.mg-timer-bar.warn   { background: #ff9800; }
.mg-timer-bar.danger { background: #f44336; }

/* ── Canvas wrapper ── */
.mg-canvas-wrap {
    position: relative;
    flex: 1;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    width: 100%;
    overflow: hidden;
}

#mg-canvas {
    display: block;
    border-radius: 8px;
    image-rendering: pixelated;
    image-rendering: crisp-edges;
}

/* ── HUD below canvas ── */
.mg-hud {
    width: 100%;
    padding: 3px 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 28px;
    box-sizing: border-box;
    flex-shrink: 0;
}

.mg-hint {
    font-size: 11px;
    color: #666;
}

.mg-found-items {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    justify-content: flex-end;
}

.mg-item-chip {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 2px 8px;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    color: #ddd;
}

/* ── End screen (overlaid on canvas wrap) ── */
.mg-end-screen {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    border-radius: 8px;
    z-index: 5;
    animation: mg-fade-in 0.3s ease;
}

@keyframes mg-fade-in {
    from { opacity: 0; transform: scale(0.97); }
    to   { opacity: 1; transform: scale(1); }
}

.mg-end-title {
    font-size: 20px;
    font-weight: bold;
    color: var(--primary);
}

.mg-end-subtitle {
    font-size: 13px;
    color: #888;
    margin-top: -10px;
}

.mg-end-items {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    max-width: 340px;
    padding: 0 16px;
}

.mg-end-item {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 10px;
    padding: 5px 12px;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: #eee;
}

.mg-end-empty {
    color: #666;
    font-size: 13px;
}

.mg-stats-block {
    display: flex;
    flex-direction: column;
    gap: 5px;
    width: 210px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 8px;
    padding: 10px 14px;
}

.mg-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 12px;
}

.mg-stat-label {
    color: #555;
}

.mg-stat-val {
    font-weight: bold;
    font-size: 13px;
}

.mg-collect-btn {
    padding: 11px 36px;
    background: var(--primary);
    color: #000;
    border: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    margin-top: 4px;
    transition: transform 0.1s, opacity 0.1s;
}

.mg-collect-btn:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* ── Mobile D-Pad ── */
.mg-dpad {
    display: none;
    position: absolute;
    bottom: 14px;
    left: 14px;
    grid-template-columns: 48px 48px 48px;
    grid-template-rows: 48px 48px 48px;
    gap: 2px;
}

.mg-dpad-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    border-radius: 6px;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    transition: background 0.08s;
}

.mg-dpad-btn:active,
.mg-dpad-btn.pressed {
    background: rgba(255, 255, 255, 0.28);
}

.mg-dpad-btn.dpad-up    { grid-column: 2; grid-row: 1; }
.mg-dpad-btn.dpad-left  { grid-column: 1; grid-row: 2; }
.mg-dpad-btn.dpad-act   { grid-column: 2; grid-row: 2; font-size: 11px; background: rgba(200,168,107,0.25); }
.mg-dpad-btn.dpad-right { grid-column: 3; grid-row: 2; }
.mg-dpad-btn.dpad-down  { grid-column: 2; grid-row: 3; }

/* Show dpad on touch devices */
@media (pointer: coarse) {
    .mg-dpad { display: grid; }
    .mg-hint { display: none; }
}

/* ── Inline size select (in activity card) ── */
.mg-size-select {
    padding: 6px 10px;
    background: var(--background);
    border: 1px solid #444;
    border-radius: 6px;
    color: var(--text);
    font-size: 13px;
    cursor: pointer;
}
.mg-size-select:focus { outline: none; border-color: var(--primary); }

/* ── Size picker ── */
.mg-size-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 340px;
    padding: 4px 16px;
}

.mg-size-btn {
    padding: 8px 14px;
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 8px;
    color: #bbb;
    font-size: 13px;
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.mg-size-btn:hover { background: rgba(255, 255, 255, 0.12); border-color: rgba(255, 255, 255, 0.28); }
.mg-size-btn.active { background: rgba(200, 168, 107, 0.18); border-color: var(--primary); color: var(--primary); font-weight: bold; }

/* ── Property page character selector ── */
.mg-char-strip {
    display: flex;
    align-items: center;
    gap: 14px;
    max-width: 600px;
    margin: 0 auto 16px;
    padding: 10px 16px;
    background: var(--surface);
    border-radius: 10px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-sizing: border-box;
}

.mg-char-strip-label {
    font-size: 12px;
    color: #888;
    white-space: nowrap;
}

.mg-char-strip-opts {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.mg-char-opt {
    flex-shrink: 0;
    width: 88px;
    height: 100px;
    border-radius: 10px;
    border: 2px solid rgba(255, 255, 255, 0.1);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.04);
    transition: border-color 0.15s, background 0.15s;
    overflow: hidden;
}

.mg-char-opt img {
    width: 72px;
    height: 80px;
    image-rendering: pixelated;
    object-fit: contain;
    pointer-events: none;
}

.mg-char-opt:hover {
    border-color: rgba(255, 255, 255, 0.28);
    background: rgba(255, 255, 255, 0.08);
}

.mg-char-opt.active {
    border-color: var(--primary);
    background: rgba(200, 168, 107, 0.14);
}

/* END: Minigame Styles */
