:root {
    --font-main: 'Outfit', sans-serif;
    --font-title: 'Fredoka', sans-serif;
    --header-bg: #ffffff;
    --panel-bg: #ffffff;
    --text-color: #1f2b2c;
    --muted-text: #576567;
    --accent-color: #0f8b8d;
    --accent-soft: #d6f0ed;
    --success-color: #2a9d8f;
    --warning-color: #f4a261;
    --error-color: #d64545;
    --bg-color: #e9f3f3;
    --bg-accent-1: #d8efea;
    --bg-accent-2: #f7f2de;
    --tray-bg: #e8ecef;
    --rack-bg: #e3edf0;
    --register-text: #cc6f2d;
    --shadow-soft: 0 10px 30px rgba(14, 48, 52, 0.12);
    --header-height: 120px;
}

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

body {
    font-family: var(--font-main);
    color: var(--text-color);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    background: radial-gradient(circle at top left, var(--bg-accent-1), var(--bg-color) 50%),
        radial-gradient(circle at 90% 90%, var(--bg-accent-2), transparent 50%);
}

body::before,
body::after {
    content: '';
    position: fixed;
    border-radius: 50%;
    z-index: -1;
    opacity: 0.5;
}

body::before {
    width: 360px;
    height: 360px;
    right: -110px;
    top: 45%;
    background: color-mix(in srgb, var(--accent-color) 12%, white);
}

body::after {
    width: 260px;
    height: 260px;
    left: -80px;
    top: 15%;
    background: color-mix(in srgb, var(--accent-color) 10%, white);
}

body.scene-us {
    --accent-color: #1b4f72;
    --accent-soft: #d4e6f7;
    --bg-color: #edf4fb;
    --bg-accent-1: #d9e9fa;
    --bg-accent-2: #fff3d5;
    --rack-bg: #dbe8f7;
    --register-text: #b66a2d;
}

body.scene-br {
    --accent-color: #0d7a3d;
    --accent-soft: #d6f2df;
    --bg-color: #eff8ef;
    --bg-accent-1: #d8f0d4;
    --bg-accent-2: #fff0b5;
    --rack-bg: #deefd4;
    --register-text: #a06d00;
}

body.scene-stamps {
    --accent-color: #a73a46;
    --accent-soft: #ffe1e4;
    --bg-color: #fff7ea;
    --bg-accent-1: #ffe5c9;
    --bg-accent-2: #ffdeda;
    --rack-bg: #f5e4d2;
    --register-text: #99443f;
}

header {
    min-height: var(--header-height);
    background: var(--header-bg);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.9rem 1.75rem;
    gap: 1rem;
    box-shadow: 0 2px 16px rgba(20, 31, 33, 0.08);
    flex-wrap: wrap;
}

.header-content {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex: 1;
    min-width: 260px;
}

.header-content h1 {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--accent-color);
    letter-spacing: 0.02em;
}

.controls {
    display: flex;
    align-items: center;
}

.controls button {
    border: none;
    background: color-mix(in srgb, var(--accent-color) 14%, white);
    border-radius: 12px;
    padding: 0.35rem 0.6rem;
    font-size: 1.35rem;
    cursor: pointer;
    margin-left: 0.6rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.controls button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(22, 45, 48, 0.2);
}

.scene-selector {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

.scene-btn {
    padding: 0.5rem 0.9rem;
    border: 2px solid transparent;
    border-radius: 999px;
    background: color-mix(in srgb, var(--accent-color) 12%, white);
    color: var(--text-color);
    font-weight: 700;
    font-size: 0.88rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.scene-btn:hover {
    border-color: color-mix(in srgb, var(--accent-color) 55%, white);
}

.scene-btn.active {
    background: var(--accent-color);
    color: #fff;
    box-shadow: 0 6px 14px rgba(30, 53, 56, 0.2);
}

.scene-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.hidden {
    display: none !important;
}

#start-screen {
    position: fixed;
    inset: 0;
    z-index: 1400;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    background: radial-gradient(circle at 20% 25%, color-mix(in srgb, var(--accent-color) 14%, white), rgba(255, 255, 255, 0.82) 52%),
        rgba(248, 252, 253, 0.88);
    backdrop-filter: blur(2px);
}

.start-card {
    width: min(560px, 92vw);
    text-align: center;
    background: #ffffff;
    border: 1px solid rgba(24, 42, 48, 0.08);
    border-radius: 20px;
    box-shadow: 0 16px 36px rgba(13, 24, 28, 0.2);
    padding: 2rem 1.4rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

#start-title {
    font-family: var(--font-title);
    font-size: 2rem;
    color: var(--accent-color);
    line-height: 1.15;
}

#start-subtitle {
    color: var(--muted-text);
    font-size: 1rem;
}

#start-play-btn {
    align-self: center;
    margin-top: 0.5rem;
    min-width: 170px;
    border: none;
    border-radius: 999px;
    background: var(--accent-color);
    color: #fff;
    font-family: var(--font-title);
    font-size: 1.1rem;
    font-weight: 700;
    padding: 0.7rem 1.4rem;
    cursor: pointer;
    box-shadow: 0 10px 20px rgba(18, 44, 51, 0.22);
    transition: transform 0.15s ease, filter 0.15s ease;
}

#start-play-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.05);
}

#game-container {
    flex: 1;
    display: flex;
    width: 100%;
    max-width: 1440px;
    margin: 0 auto;
    padding: 1.4rem;
    gap: 1.2rem;
    align-items: flex-start;
}

#algo-panel {
    flex: 0 0 640px;
    min-width: 600px;
    background: var(--panel-bg);
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    padding: 1rem;
    max-height: calc(100vh - 140px);
    overflow-y: auto;
}

.algo-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.55rem;
    margin-bottom: 0.9rem;
}

.algo-header h2 {
    font-family: var(--font-title);
    color: var(--accent-color);
    font-size: 1.25rem;
}

.algo-controls {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    flex-wrap: wrap;
    justify-content: flex-end;
}

#algo-select,
#algo-speed-select,
#run-btn,
#run-algo-btn {
    border-radius: 10px;
    border: 1px solid color-mix(in srgb, var(--accent-color) 30%, white);
    padding: 0.45rem 0.55rem;
    font-family: inherit;
    font-weight: 600;
}

#algo-select {
    min-width: 180px;
}

#algo-speed-select {
    min-width: 78px;
}

#algo-speed-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 700;
    color: var(--muted-text);
    padding-left: 0.1rem;
}

#run-btn,
#run-algo-btn {
    background: var(--accent-color);
    color: #fff;
    border: none;
    cursor: pointer;
}

#code-display {
    background: #152028;
    color: #dce7ee;
    border-radius: 10px;
    padding: 0.8rem;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 0.85rem;
    max-height: 330px;
    overflow-y: auto;
    overflow-x: auto;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.code-line {
    padding: 0.15rem 0.25rem;
    border-radius: 4px;
    white-space: pre;
    word-break: normal;
}

.code-line.highlight {
    background: rgba(233, 138, 66, 0.28);
    color: inherit;
    font-weight: 700;
    box-shadow: inset 0 0 0 1px rgba(233, 138, 66, 0.55);
}

.code-token.keyword {
    color: #8fd3ff;
    font-weight: 700;
}

.code-token.builtin {
    color: #c7a6ff;
}

.code-token.function {
    color: #7fe0c9;
}

.code-token.string {
    color: #f2c285;
}

.code-token.number {
    color: #ffd76e;
}

.code-token.operator {
    color: #f4a4b8;
}

.code-token.punctuation {
    color: #89a1ad;
}

.code-token.comment {
    color: #8aa0ab;
    font-style: italic;
}

#dp-visualization {
    margin-top: 0.7rem;
    border: 1px solid #e2e8eb;
    border-radius: 10px;
    background: #f8fbfc;
    padding: 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.dp-vis-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.dp-vis-header strong {
    color: #1f3f4f;
    font-size: 0.85rem;
    letter-spacing: 0.02em;
}

#dp-vis-context {
    color: #56666b;
    font-size: 0.74rem;
}

.dp-vis-meta {
    display: flex;
    gap: 0.55rem;
    flex-wrap: wrap;
}

.dp-vis-meta span {
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 0.72rem;
    color: #31474f;
    background: #eef3f5;
    border: 1px solid #d8e4e8;
    border-radius: 999px;
    padding: 0.12rem 0.52rem;
}

.dp-vis-scroll {
    border: 1px solid #dce7eb;
    border-radius: 8px;
    background: #ffffff;
    overflow-x: auto;
}

#dp-vis-table {
    border-collapse: collapse;
    width: max-content;
    min-width: 100%;
}

#dp-vis-table tr:first-child {
    background: #f2f7f9;
}

#dp-vis-table th,
#dp-vis-table td {
    border-right: 1px solid #edf3f6;
    border-bottom: 1px solid #edf3f6;
    text-align: center;
    min-width: 38px;
    height: 28px;
    padding: 0 0.22rem;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-size: 0.68rem;
    white-space: nowrap;
}

#dp-vis-table tr:last-child td,
#dp-vis-table tr:last-child th {
    border-bottom: none;
}

#dp-vis-table td:last-child,
#dp-vis-table th:last-child {
    border-right: none;
}

.dp-row-label {
    position: sticky;
    left: 0;
    z-index: 2;
    min-width: 150px !important;
    background: #eef4f7;
    color: #29414c;
    font-weight: 700;
}

.dp-cell-index {
    color: #5a6d75;
    background: #f8fbfc;
}

.dp-cell-unset {
    color: #9babb3;
}

.dp-cell-inf {
    color: #b66a2d;
    font-weight: 700;
    background: #fff6ea;
}

.dp-cell-value {
    color: #183640;
    font-weight: 700;
}

.dp-cell-current {
    box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent-color) 50%, white);
    background: color-mix(in srgb, var(--accent-color) 16%, white);
}

.dp-cell-updated {
    background: color-mix(in srgb, var(--success-color) 24%, white);
}

.dp-cell-path {
    background: color-mix(in srgb, var(--warning-color) 32%, white);
}

#algo-steps {
    margin-top: 0.8rem;
    border-top: 1px solid #e4e8ea;
    padding-top: 0.8rem;
    color: var(--muted-text);
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
    max-height: 420px;
    overflow-y: auto;
}

.game-area {
    flex: 1;
    background: rgba(255, 255, 255, 0.92);
    border: 1px solid rgba(255, 255, 255, 0.7);
    border-radius: 24px;
    box-shadow: var(--shadow-soft);
    padding: 1.1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.game-topbar {
    display: flex;
    justify-content: space-between;
    gap: 1rem;
    align-items: center;
    flex-wrap: wrap;
}

.scene-meta h2 {
    font-family: var(--font-title);
    color: var(--accent-color);
    font-size: 1.45rem;
}

.scene-meta p {
    color: var(--muted-text);
    font-size: 0.95rem;
}

.score-pill {
    background: var(--accent-soft);
    border-radius: 14px;
    padding: 0.45rem 0.8rem;
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    color: var(--text-color);
    min-width: 200px;
}

.score-row {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.6rem;
}

#served-label,
#mistake-label,
#success-label {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
}

#served-count,
#mistake-count,
#success-rate {
    font-family: var(--font-title);
    font-size: 1.25rem;
}

.customer-area {
    position: relative;
    min-height: 210px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    gap: 1.2rem;
    padding-top: 0.9rem;
}

.current-customer {
    order: 1;
    position: relative;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.queue-container {
    --queue-shift-offset: 0px;
    --queue-shift-duration: 700ms;
    order: 2;
    display: flex;
    gap: 0.55rem;
    opacity: 0.6;
    transform: translateX(var(--queue-shift-offset)) scale(0.84);
    transform-origin: bottom left;
    transition: transform var(--queue-shift-duration) cubic-bezier(0.2, 0.9, 0.3, 1);
    will-change: transform;
}

.queue-container.queue-resetting {
    transition: none;
}

.thought-bubble {
    position: absolute;
    top: -64px;
    background: #fff;
    color: var(--text-color);
    border-radius: 18px;
    padding: 0.65rem 1rem;
    box-shadow: 0 10px 20px rgba(30, 39, 44, 0.16);
    font-weight: 700;
    white-space: nowrap;
    z-index: 30;
    transition: opacity 0.25s ease;
}

.thought-bubble::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -9px;
    transform: translateX(-50%);
    border-width: 10px 10px 0;
    border-style: solid;
    border-color: #fff transparent transparent transparent;
}

.character {
    width: 64px;
    height: 95px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: transparent;
    font-size: 0.64rem;
    font-weight: 700;
    position: relative;
    margin-top: 32px;
    background-color: transparent !important;
}

.character::before {
    content: '';
    position: absolute;
    top: -34px;
    left: 50%;
    transform: translateX(-50%);
    width: 38px;
    height: 38px;
    background: var(--char-color);
    border-radius: 999px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.15);
    z-index: 2;
}

.character::after {
    content: '';
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: var(--char-color);
    z-index: 1;
}

.headwear {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--hat-color, #2f3640);
    pointer-events: none;
    z-index: 4;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.28);
}

.headwear-cap {
    top: -43px;
    width: 36px;
    height: 15px;
    border-radius: 16px 16px 9px 9px;
}

.headwear-cap::after {
    content: '';
    position: absolute;
    left: 22px;
    top: 10px;
    width: 18px;
    height: 6px;
    background: inherit;
    border-radius: 0 6px 7px 4px;
    transform: rotate(-14deg);
}

.headwear-hat {
    top: -52px;
    width: 30px;
    height: 24px;
    border-radius: 8px 8px 4px 4px;
}

.headwear-hat::after {
    content: '';
    position: absolute;
    left: 50%;
    bottom: -4px;
    width: 46px;
    height: 7px;
    transform: translateX(-50%);
    background: inherit;
    border-radius: 999px;
}

.neckwear {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    background: var(--tie-color, #8b1e3f);
    pointer-events: none;
    z-index: 5;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.neckwear-bowtie {
    top: -2px;
    width: 9px;
    height: 9px;
    border-radius: 50%;
}

.neckwear-bowtie::before,
.neckwear-bowtie::after {
    content: '';
    position: absolute;
    top: 1px;
    width: 10px;
    height: 8px;
    background: inherit;
}

.neckwear-bowtie::before {
    left: -8px;
    clip-path: polygon(100% 50%, 0 0, 0 100%);
}

.neckwear-bowtie::after {
    right: -8px;
    clip-path: polygon(0 50%, 100% 0, 100% 100%);
}

.neckwear-tie {
    top: 2px;
    width: 11px;
    height: 23px;
    clip-path: polygon(45% 0, 55% 0, 85% 74%, 50% 100%, 15% 74%);
}

.neckwear-tie::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -4px;
    width: 9px;
    height: 7px;
    background: inherit;
    transform: translateX(-50%);
    clip-path: polygon(18% 0, 82% 0, 100% 55%, 50% 100%, 0 55%);
    border-radius: 1px;
}

.eyewear {
    position: absolute;
    left: 50%;
    top: -18px;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 4;
}

.eyewear-glasses {
    width: 8px;
    height: 2px;
    background: var(--eyewear-color, #2f3640);
    border-radius: 2px;
}

.eyewear-glasses::before,
.eyewear-glasses::after {
    content: '';
    position: absolute;
    top: -3px;
    width: 11px;
    height: 8px;
    border-radius: 4px;
    border: 2px solid var(--eyewear-color, #2f3640);
    background: rgba(255, 255, 255, 0.16);
}

.eyewear-glasses::before {
    left: -12px;
}

.eyewear-glasses::after {
    right: -12px;
}

.eyewear-sunglasses {
    width: 9px;
    height: 2px;
    background: var(--eyewear-color, #1f2937);
    border-radius: 2px;
}

.eyewear-sunglasses::before,
.eyewear-sunglasses::after {
    content: '';
    position: absolute;
    top: -2px;
    width: 12px;
    height: 8px;
    border-radius: 4px;
    border: 1px solid rgba(17, 24, 39, 0.6);
    background: color-mix(in srgb, var(--eyewear-color, #1f2937) 78%, black);
}

.eyewear-sunglasses::before {
    left: -13px;
}

.eyewear-sunglasses::after {
    right: -13px;
}

.current-customer .eyewear {
    top: -21px;
    transform: translateX(-50%) scale(1.14);
}

.shopping-bag {
    position: absolute;
    left: 70%;
    top: 66%;
    transform: translate(-50%, -50%) rotate(var(--bag-rotation, -4deg));
    background: var(--bag-color, #d8b691);
    pointer-events: none;
    z-index: 3;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.22);
    border: 1px solid rgba(24, 38, 43, 0.25);
}

.shape-circle > .shopping-bag {
    top: 64%;
}

.shape-pentagon > .shopping-bag {
    top: 67%;
}

.current-customer .character > .shopping-bag {
    left: 70%;
    top: 64%;
    transform: translate(-50%, -50%) rotate(var(--bag-rotation, -4deg)) scale(1.12);
}

.shopping-bag-paper {
    width: 18px;
    height: 22px;
    border-radius: 2px 2px 4px 4px;
}

.shopping-bag-paper::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -7px;
    width: 11px;
    height: 8px;
    transform: translateX(-50%);
    border: 2px solid rgba(24, 38, 43, 0.45);
    border-bottom: none;
    border-radius: 9px 9px 0 0;
}

.shopping-bag-plastic {
    width: 19px;
    height: 20px;
    border-radius: 5px 5px 4px 4px;
    box-shadow: inset 0 -5px 0 rgba(255, 255, 255, 0.18), 0 2px 4px rgba(0, 0, 0, 0.22);
}

.shopping-bag-plastic::before {
    content: '';
    position: absolute;
    left: 50%;
    top: -6px;
    width: 10px;
    height: 7px;
    transform: translateX(-50%);
    border: 2px solid rgba(24, 38, 43, 0.45);
    border-bottom: none;
    border-radius: 9px 9px 0 0;
    background: rgba(255, 255, 255, 0.28);
}

.shopping-bag-gift {
    width: 18px;
    height: 18px;
    border-radius: 2px;
}

.shopping-bag-gift::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 4px;
    height: 100%;
    transform: translateX(-50%);
    background: rgba(255, 255, 255, 0.6);
}

.shopping-bag-gift::after {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    width: 100%;
    height: 4px;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.6);
}

.mail-item {
    display: block;
    position: relative;
    pointer-events: none;
    background: var(--mail-item-color, #fff8d9);
}

.character > .mail-item {
    position: absolute;
    left: 58%;
    top: 64%;
    transform: translate(-50%, -50%) rotate(var(--mail-rotation, -8deg)) scale(1.08);
    z-index: 3;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.shape-circle > .mail-item {
    top: 62%;
}

.shape-pentagon > .mail-item {
    top: 66%;
}

.current-customer .character > .mail-item {
    left: 58%;
    top: 62%;
    transform: translate(-50%, -50%) rotate(var(--mail-rotation, -8deg)) scale(1.18);
}

.mail-letter {
    width: 24px;
    height: 17px;
    border-radius: 2px;
    border: 1px solid rgba(24, 38, 43, 0.28);
}

.mail-letter::before {
    content: '';
    position: absolute;
    left: -1px;
    right: -1px;
    bottom: -1px;
    height: 9px;
    background: color-mix(in srgb, var(--mail-item-color, #fff8d9) 90%, #f1e3ae);
    border: 1px solid rgba(24, 38, 43, 0.24);
    border-top: none;
    clip-path: polygon(0 0, 50% 100%, 100% 0);
}

.mail-postcard {
    width: 23px;
    height: 16px;
    border-radius: 2px;
    border: 1px solid rgba(24, 38, 43, 0.3);
}

.mail-postcard::before {
    content: '';
    position: absolute;
    top: 3px;
    right: 3px;
    width: 6px;
    height: 6px;
    border-radius: 1px;
    background: #f8f8ff;
    border: 1px solid rgba(24, 38, 43, 0.2);
}

.mail-postcard::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 4px;
    width: 9px;
    height: 2px;
    background: rgba(24, 38, 43, 0.35);
    box-shadow: 0 4px 0 rgba(24, 38, 43, 0.35), 0 8px 0 rgba(24, 38, 43, 0.25);
}

.mail-box {
    width: 22px;
    height: 18px;
    border-radius: 2px;
    border: 1px solid rgba(24, 38, 43, 0.3);
}

.mail-box::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 0;
    width: 5px;
    height: 100%;
    transform: translateX(-50%);
    background: rgba(255, 243, 214, 0.82);
}

.mail-box::after {
    content: '';
    position: absolute;
    left: 1px;
    right: 1px;
    top: 2px;
    height: 5px;
    background: rgba(255, 243, 214, 0.45);
}

.drop-tray-items .mail-item {
    pointer-events: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transform: none;
    transform-origin: center;
}

.drop-tray-items .mail-letter {
    width: min(100%, 28px);
    height: min(100%, 20px);
}

.drop-tray-items .mail-letter::before {
    height: 9px;
}

.drop-tray-items .mail-postcard {
    width: min(100%, 28px);
    height: min(100%, 20px);
}

.drop-tray-items .mail-postcard::before {
    width: 7px;
    height: 7px;
    right: 3px;
    top: 3px;
}

.drop-tray-items .mail-postcard::after {
    left: 4px;
    width: 9px;
    box-shadow: 0 4px 0 rgba(24, 38, 43, 0.35), 0 8px 0 rgba(24, 38, 43, 0.25);
}

.drop-tray-items .mail-box {
    width: min(100%, 26px);
    height: min(100%, 20px);
}

.drop-tray-items .mail-box::before {
    width: 6px;
}

.drop-tray-items .mail-box::after {
    top: 2px;
    height: 5px;
}

.slip-item {
    display: block;
    position: relative;
    background: var(--slip-color, #fffef2);
    border: 1px solid rgba(24, 38, 43, 0.24);
    border-radius: 2px;
}

.drop-tray-items .slip-item {
    width: min(100%, 28px);
    height: min(100%, 20px);
    transform: rotate(var(--slip-rotation, -3deg));
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.drop-tray-items .slip-receipt::before {
    content: '';
    position: absolute;
    left: 4px;
    top: 4px;
    width: 11px;
    height: 2px;
    background: rgba(24, 38, 43, 0.35);
    box-shadow: 0 4px 0 rgba(24, 38, 43, 0.3), 0 8px 0 rgba(24, 38, 43, 0.25);
}

.drop-tray-items .slip-coupon::before {
    content: '';
    position: absolute;
    top: 2px;
    bottom: 2px;
    left: 50%;
    width: 2px;
    transform: translateX(-50%);
    background: rgba(24, 38, 43, 0.25);
    border-radius: 999px;
}

.drop-tray-items .slip-coupon::after {
    content: '';
    position: absolute;
    left: 4px;
    top: 5px;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    border: 1px solid rgba(24, 38, 43, 0.32);
}

.drop-tray-items .slip-invoice::before {
    content: '';
    position: absolute;
    right: 3px;
    top: 3px;
    width: 7px;
    height: 7px;
    border-radius: 2px;
    background: rgba(124, 183, 233, 0.55);
    border: 1px solid rgba(24, 38, 43, 0.25);
}

.drop-tray-items .slip-invoice::after {
    content: '';
    position: absolute;
    left: 4px;
    bottom: 4px;
    width: 12px;
    height: 2px;
    background: rgba(24, 38, 43, 0.3);
}

.shape-rect::after {
    border-radius: 10px 10px 4px 4px;
}

.shape-circle::after {
    border-radius: 34px;
}

.shape-pentagon::after {
    clip-path: polygon(50% 0%, 100% 25%, 85% 100%, 15% 100%, 0% 25%);
}

.shape-triangle::after {
    width: 0;
    height: 0;
    left: 50%;
    transform: translateX(-50%);
    border-left: 32px solid transparent;
    border-right: 32px solid transparent;
    border-bottom: 95px solid var(--char-color);
    background: transparent;
}

.current-customer .character {
    width: 76px;
    height: 118px;
}

.current-customer .character::before {
    width: 44px;
    height: 44px;
}

.current-customer .headwear-cap {
    top: -50px;
    width: 46px;
    height: 18px;
}

.current-customer .headwear-cap::after {
    left: 28px;
    top: 12px;
    width: 20px;
    height: 7px;
}

.current-customer .headwear-hat {
    top: -58px;
    width: 36px;
    height: 28px;
}

.current-customer .headwear-hat::after {
    width: 56px;
    height: 8px;
    bottom: -5px;
}

.current-customer .neckwear-bowtie {
    top: 2px;
    width: 11px;
    height: 11px;
}

.current-customer .neckwear-bowtie::before,
.current-customer .neckwear-bowtie::after {
    top: 1px;
    width: 12px;
    height: 10px;
}

.current-customer .neckwear-bowtie::before {
    left: -10px;
}

.current-customer .neckwear-bowtie::after {
    right: -10px;
}

.current-customer .neckwear-tie {
    top: 5px;
    width: 13px;
    height: 30px;
}

.current-customer .neckwear-tie::before {
    top: -5px;
    width: 11px;
    height: 8px;
}

.register-area {
    background: var(--panel-bg);
    border-radius: 20px;
    box-shadow: 0 10px 24px rgba(19, 29, 31, 0.1);
    border: 1px solid rgba(31, 43, 44, 0.06);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.85rem;
}

.register-label {
    font-weight: 700;
    color: var(--muted-text);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-size: 0.8rem;
}

.counter-top-row {
    display: flex;
    gap: 0.7rem;
    align-items: stretch;
}

.register-display {
    flex: 1;
    font-size: 3rem;
    font-family: ui-monospace, 'SFMono-Regular', Menlo, Monaco, Consolas, monospace;
    font-weight: 700;
    color: var(--register-text);
    text-align: center;
    border-radius: 14px;
    background: color-mix(in srgb, var(--accent-color) 8%, white);
    padding: 0.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.drop-tray-panel {
    display: none;
    width: min(236px, 40%);
    min-width: 176px;
    border-radius: 14px;
    padding: 0.45rem;
    background: color-mix(in srgb, var(--accent-color) 10%, #fff);
    border: 1px solid rgba(28, 43, 47, 0.14);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.55);
    gap: 0.38rem;
    flex-direction: column;
}

.scene-stamps .drop-tray-panel,
.scene-us .drop-tray-panel {
    display: flex;
}

.drop-tray-label {
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    font-size: 0.67rem;
    color: var(--muted-text);
}

.drop-tray-items {
    --drop-tray-cols: 6;
    --drop-tray-rows: 3;
    min-height: 108px;
    max-height: 108px;
    border-radius: 10px;
    padding: 0.34rem;
    background: rgba(255, 255, 255, 0.7);
    border: 1px dashed rgba(31, 43, 44, 0.25);
    display: grid;
    grid-template-columns: repeat(var(--drop-tray-cols), minmax(0, 1fr));
    grid-template-rows: repeat(var(--drop-tray-rows), minmax(0, 1fr));
    align-items: center;
    justify-items: center;
    gap: 0.28rem;
    overflow: hidden;
}

.drop-tray-slot {
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    border-radius: 4px;
}

.drop-tray-count {
    margin: 0;
    text-align: right;
    font-size: 0.72rem;
    color: var(--muted-text);
    font-weight: 600;
}

.coins-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(86px, 1fr));
    gap: 0.75rem;
    background: var(--rack-bg);
    border-radius: 16px;
    padding: 0.75rem;
}

.coin-slot {
    min-height: 86px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.65);
    border: 1px solid rgba(31, 43, 44, 0.08);
    box-shadow: inset 0 -3px 4px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
}

.coin-btn {
    border: none;
    border-radius: 50%;
    box-shadow: 0 4px 0 rgba(0, 0, 0, 0.2);
    cursor: pointer;
    font-family: var(--font-title);
    font-weight: 800;
    color: #1f2b2c;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    font-size: 0.82rem;
    line-height: 1.05;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 1px rgba(0, 0, 0, 0.28);
    transition: transform 0.08s ease, box-shadow 0.08s ease;
    border: 1px solid rgba(22, 36, 40, 0.18);
    padding: 0.15rem;
}

.coin-btn:hover {
    transform: translateY(-1px);
}

.coin-btn:active {
    transform: translateY(3px);
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.2);
}

.scene-stamps .coin-btn,
.scene-stamps .tray-coin {
    border-radius: 7px;
}

.selected-coins {
    min-height: 84px;
    background: var(--tray-bg);
    border-radius: 12px;
    display: flex;
    align-items: center;
    padding: 0.55rem;
    gap: 0.45rem;
    overflow-x: auto;
    border: 1px dashed color-mix(in srgb, var(--accent-color) 35%, white);
}

.tray-coin {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffd84d;
    border: 1px solid rgba(22, 36, 40, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: var(--font-title);
    font-size: 0.74rem;
    font-weight: 800;
    color: #1e2d30;
    font-variant-numeric: tabular-nums;
    line-height: 1.05;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.45), 0 0 1px rgba(0, 0, 0, 0.25);
    flex-shrink: 0;
    box-shadow: 0 3px 6px rgba(0, 0, 0, 0.15);
}

.action-row {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 0.6rem;
}

#submit-btn,
#clear-btn,
#restart-btn {
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.96rem;
    padding: 0.75rem 0.85rem;
    cursor: pointer;
    transition: transform 0.14s ease, filter 0.14s ease;
}

#submit-btn {
    background: var(--success-color);
    color: #fff;
}

#clear-btn {
    background: var(--warning-color);
    color: #1f2a2c;
}

#restart-btn {
    background: var(--error-color);
    color: #fff;
}

#submit-btn:hover,
#clear-btn:hover,
#restart-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.03);
}

#submit-btn:disabled,
#clear-btn:disabled,
#restart-btn:disabled,
#run-btn:disabled,
#run-algo-btn:disabled,
.coin-btn:disabled {
    opacity: 0.55;
    cursor: not-allowed;
    transform: none;
}

.coins-container.is-disabled {
    opacity: 0.62;
}

#modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(18, 26, 30, 0.55);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal {
    width: min(520px, 100%);
    background: #fff;
    border-radius: 18px;
    padding: 1.2rem;
    text-align: left;
    box-shadow: 0 12px 30px rgba(11, 17, 19, 0.25);
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
}

.modal h2 {
    font-family: var(--font-title);
    color: var(--accent-color);
}

.modal-content {
    color: #344345;
    white-space: pre-line;
    line-height: 1.45;
}

.modal-content.is-html {
    white-space: normal;
}

.modal-content p {
    margin: 0.35rem 0;
}

.modal-content ol {
    margin: 0.3rem 0 0.2rem 1.1rem;
    padding: 0;
}

.modal-content li {
    margin: 0.35rem 0;
}

.modal-content a {
    color: var(--accent-color);
    font-weight: 700;
    text-decoration: none;
}

.modal-content a:hover {
    text-decoration: underline;
}

.ref-heading {
    margin-top: 0.55rem;
    margin-bottom: 0.2rem;
    font-weight: 700;
    color: #243436;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

#close-modal,
#modal-secondary {
    border: none;
    border-radius: 10px;
    padding: 0.55rem 0.9rem;
    font-weight: 700;
    cursor: pointer;
}

#close-modal {
    background: #edf3f4;
    color: #1f2a2c;
}

#modal-secondary {
    background: var(--accent-color);
    color: #fff;
}

.status-message {
    min-height: 44px;
    border-radius: 12px;
    border: 1px solid rgba(21, 42, 45, 0.1);
    background: rgba(255, 255, 255, 0.72);
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 0.5rem 0.7rem;
    font-weight: 700;
    color: #3b4d4f;
    opacity: 0;
    transform: translateY(4px);
    transition: opacity 0.18s ease, transform 0.18s ease, background-color 0.18s ease;
}

.status-message.visible {
    opacity: 1;
    transform: translateY(0);
}

.status-message.good {
    background: color-mix(in srgb, var(--success-color) 20%, white);
    color: #11544b;
}

.status-message.bad {
    background: #f7d089;
    color: #2f2b22;
}

footer {
    margin-top: auto;
    text-align: center;
    color: #5b6a6d;
    font-size: 0.82rem;
    padding: 0.9rem 1rem 1.1rem;
}

.footer-meta {
    max-width: 1200px;
    margin: 0.2rem auto;
    line-height: 1.5;
    word-break: break-word;
}

.links {
    display: flex;
    gap: 0.75rem;
    justify-content: center;
    margin-top: 0.35rem;
    flex-wrap: wrap;
}

.links a {
    color: var(--accent-color);
    text-decoration: none;
    font-weight: 700;
}

.links a:hover {
    text-decoration: underline;
}

@media (max-width: 1120px) {
    #game-container {
        flex-direction: column;
    }

    #algo-panel {
        width: 100%;
        flex: 1;
        min-width: 0;
        max-height: none;
    }

    .drop-tray-items {
        --drop-tray-cols: 5;
    }
}

@media (max-width: 760px) {
    header {
        padding: 0.8rem 0.9rem;
    }

    .header-content h1 {
        font-size: 1.7rem;
    }

    .scene-selector {
        width: 100%;
        justify-content: flex-start;
    }

    #game-container {
        padding: 0.8rem;
    }

    .action-row {
        grid-template-columns: 1fr;
    }

    .register-display {
        font-size: 2.35rem;
    }

    .counter-top-row {
        flex-direction: column;
    }

    .drop-tray-panel {
        width: 100%;
        min-width: 0;
    }

    .drop-tray-items {
        --drop-tray-cols: 4;
        --drop-tray-rows: 3;
        min-height: 88px;
        max-height: 88px;
    }

    .customer-area {
        justify-content: space-between;
        gap: 0.6rem;
    }

    .queue-container {
        transform: translateX(var(--queue-shift-offset)) scale(0.7);
        transform-origin: bottom center;
    }
}
