/* ==========================================================================
   Game-style windows: Settings + Shop
   ========================================================================== */
.gm-overlay { position: fixed; inset: 0; z-index: 60; display: flex; align-items: center; justify-content: center; padding: 1rem; background: rgba(3,1,5,.88); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); }
.gm-overlay.hidden { display: none; }
.gm-window { width: 100%; display: flex; flex-direction: column; max-height: 100%; overflow: hidden; border-radius: 1.5rem; border: 1px solid rgba(75,85,99,.6); background: linear-gradient(180deg, rgba(24,24,38,.98), rgba(10,8,16,.99)); box-shadow: 0 30px 80px rgba(0,0,0,.7), inset 0 1px 0 rgba(255,255,255,.06); animation: gmIn .22s ease; }
@keyframes gmIn { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: none; } }
.gm-head { display: flex; align-items: center; gap: 1rem; padding: .85rem 1.25rem; border-bottom: 1px solid rgba(75,85,99,.45); background: linear-gradient(90deg, rgba(220,38,38,.14), transparent 60%); }
.gm-title { font-size: 1.15rem; font-weight: 900; text-transform: uppercase; letter-spacing: .22em; color: #fff; margin-right: auto; }
.gm-close { width: 2.2rem; height: 2.2rem; border-radius: .75rem; font-weight: 900; color: #9ca3af; background: rgba(31,41,55,.85); border: 1px solid rgba(75,85,99,.6); }
.gm-close:hover { color: #fff; border-color: #ef4444; }
.gm-foot { display: flex; align-items: center; justify-content: space-between; gap: .75rem; padding: .75rem 1.25rem; border-top: 1px solid rgba(75,85,99,.45); background: rgba(0,0,0,.25); }
.gm-foot small { font-size: .65rem; color: #6b7280; line-height: 1.4; }
.gm-btn { padding: .6rem 1.1rem; border-radius: .9rem; font-weight: 900; font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; color: #e5e7eb; background: rgba(31,41,55,.85); border: 1px solid rgba(75,85,99,.6); white-space: nowrap; }
.gm-btn:not(:disabled):hover { border-color: #f59e0b; color: #fbbf24; }
.gm-btn.primary { background: linear-gradient(135deg, #dc2626, #991b1b); border-color: #ef4444; color: #fff; box-shadow: 0 4px 18px rgba(220,38,38,.35); }
.gm-btn.primary:hover { color: #fff !important; border-color: #fca5a5 !important; }
.gm-btn.buy { background: linear-gradient(135deg, #f59e0b, #b45309); border-color: #fcd34d; color: #1c1002; box-shadow: 0 4px 18px rgba(245,158,11,.35); }
.gm-btn.buy:hover { color: #1c1002 !important; }
.gm-btn.buy:disabled { background: rgba(31,41,55,.85); border-color: rgba(75,85,99,.6); color: #6b7280; box-shadow: none; }
.gm-btn.eq { background: rgba(6,78,59,.55); border-color: #059669; color: #6ee7b7; }
.gm-btn.ghost { background: transparent; color: #9ca3af; }

/* ---- Settings ---- */
.set-window { max-width: 56rem; height: min(40rem, 100%); }
.set-layout { flex: 1; min-height: 0; display: flex; }
.set-nav { width: 12.5rem; flex-shrink: 0; padding: .9rem; display: flex; flex-direction: column; gap: .35rem; border-right: 1px solid rgba(75,85,99,.45); background: rgba(0,0,0,.2); overflow-y: auto; }
.set-nav button { display: flex; align-items: center; gap: .7rem; padding: .7rem .85rem; border-radius: .9rem; text-align: left; font-weight: 900; font-size: .8rem; letter-spacing: .1em; text-transform: uppercase; color: #9ca3af; border: 1px solid transparent; }
.set-nav button i { font-style: normal; font-size: 1.1rem; }
.set-nav button:hover { color: #fff; background: rgba(31,41,55,.7); }
.set-nav button.on { color: #fff; background: linear-gradient(90deg, rgba(220,38,38,.45), rgba(220,38,38,.1)); border-color: rgba(239,68,68,.6); box-shadow: inset 3px 0 0 #f59e0b; }
.set-pages { flex: 1; min-width: 0; overflow-y: auto; padding: 1.25rem 1.5rem; }
.set-page { display: none; }
.set-page.on { display: block; animation: gmIn .18s ease; }
.set-h { font-size: 1.5rem; font-weight: 900; color: #fff; margin-bottom: 1rem; letter-spacing: .04em; }
.set-h::after { content: ''; display: block; width: 3rem; height: 3px; margin-top: .4rem; border-radius: 2px; background: linear-gradient(90deg, #f59e0b, #ef4444); }
.set-row { display: flex; align-items: center; justify-content: space-between; gap: 1.25rem; padding: .95rem 1rem; margin-bottom: .5rem; border-radius: 1rem; background: rgba(31,41,55,.45); border: 1px solid rgba(75,85,99,.35); cursor: default; }
label.set-row { cursor: pointer; }
.set-row:hover { border-color: rgba(245,158,11,.5); background: rgba(31,41,55,.7); }
.set-row.col { flex-direction: column; align-items: stretch; }
.set-label { min-width: 0; }
.set-label b { display: block; font-size: .9rem; font-weight: 800; color: #f3f4f6; }
.set-label small { display: block; margin-top: .15rem; font-size: .7rem; line-height: 1.45; color: #9ca3af; }
.set-label code { background: rgba(0,0,0,.4); padding: 0 .25rem; border-radius: .25rem; }
.set-value { font-weight: 900; font-size: .85rem; color: #fbbf24; text-transform: uppercase; letter-spacing: .1em; }
.set-slider { display: flex; align-items: center; gap: .75rem; width: 15rem; flex-shrink: 0; }
.set-slider output { width: 2.8rem; text-align: right; font-weight: 900; font-size: .8rem; color: #fbbf24; }
input[type=range].gm-range { -webkit-appearance: none; appearance: none; height: .55rem; border-radius: 99px; outline: none; cursor: pointer; --p: 50%; background: linear-gradient(90deg, #f59e0b, #ef4444) 0 / var(--p) 100% no-repeat, #1f2937; box-shadow: inset 0 1px 3px rgba(0,0,0,.6); }
input[type=range].gm-range::-webkit-slider-thumb { -webkit-appearance: none; width: 1.15rem; height: 1.15rem; border-radius: 50%; background: #fff; border: 3px solid #f59e0b; box-shadow: 0 2px 8px rgba(0,0,0,.6); transition: transform .12s; }
input[type=range].gm-range:hover::-webkit-slider-thumb { transform: scale(1.2); }
input[type=range].gm-range::-moz-range-thumb { width: .9rem; height: .9rem; border-radius: 50%; background: #fff; border: 3px solid #f59e0b; }
.gm-switch { position: relative; width: 3.1rem; height: 1.7rem; flex-shrink: 0; }
.gm-switch input { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; margin: 0; cursor: pointer; z-index: 1; }
.gm-switch i { position: absolute; inset: 0; border-radius: 99px; background: #1f2937; border: 1px solid #4b5563; transition: background .18s, border-color .18s; }
.gm-switch i::after { content: ''; position: absolute; top: 3px; left: 3px; width: 1.2rem; height: 1.2rem; border-radius: 50%; background: #9ca3af; transition: transform .18s, background .18s; }
.gm-switch input:checked + i { background: linear-gradient(135deg, #f59e0b, #dc2626); border-color: #fbbf24; }
.gm-switch input:checked + i::after { transform: translateX(1.4rem); background: #fff; }
.gm-switch input:focus-visible + i { outline: 2px solid #f59e0b; outline-offset: 2px; }
.gm-seg { display: grid; grid-template-columns: repeat(4, 1fr); gap: .35rem; padding: .3rem; border-radius: .9rem; background: rgba(0,0,0,.35); }
.gm-seg button { padding: .6rem .3rem; border-radius: .65rem; font-size: .75rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #9ca3af; }
.gm-seg button:hover { color: #fff; background: rgba(55,65,81,.7); }
.gm-seg button.on { color: #1c1002; background: linear-gradient(135deg, #fbbf24, #f59e0b); box-shadow: 0 2px 12px rgba(245,158,11,.4); }
.gm-step { display: flex; align-items: stretch; width: 15rem; flex-shrink: 0; border-radius: .9rem; overflow: hidden; border: 1px solid rgba(75,85,99,.6); background: rgba(0,0,0,.3); }
.gm-step button { width: 2.6rem; font-size: 1.4rem; font-weight: 900; color: #fbbf24; background: rgba(31,41,55,.8); }
.gm-step button:hover { background: rgba(245,158,11,.25); }
.gm-step span { flex: 1; display: flex; align-items: center; justify-content: center; padding: .55rem .5rem; font-size: .8rem; font-weight: 800; color: #fff; text-align: center; }
.set-keys { display: grid; gap: .5rem; }
.set-keys > div { display: flex; align-items: center; gap: .4rem; padding: .8rem 1rem; border-radius: 1rem; background: rgba(31,41,55,.45); border: 1px solid rgba(75,85,99,.35); color: #6b7280; }
.set-keys span { margin-left: auto; font-size: .85rem; font-weight: 700; color: #d1d5db; }
kbd { display: inline-block; min-width: 1.8rem; padding: .2rem .55rem; text-align: center; font: 900 .75rem 'Outfit', sans-serif; color: #fff; background: linear-gradient(180deg, #374151, #1f2937); border: 1px solid #4b5563; border-bottom-width: 3px; border-radius: .5rem; }

/* ---- Shop ---- */
.shop-window { max-width: 72rem; height: min(46rem, 100%); }
.shop-tabs { display: flex; gap: .3rem; padding: .25rem; border-radius: .9rem; background: rgba(0,0,0,.35); }
.shop-tabs button { padding: .5rem 1.1rem; border-radius: .65rem; font-size: .75rem; font-weight: 900; letter-spacing: .1em; text-transform: uppercase; color: #9ca3af; }
.shop-tabs button:hover { color: #fff; }
.shop-tabs button.on { color: #1c1002; background: linear-gradient(135deg, #fbbf24, #f59e0b); }
.shop-meta { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.shop-coins { font-weight: 900; font-size: 1.05rem; color: #fde047; padding: .15rem .8rem; border-radius: 99px; background: rgba(250,204,21,.1); border: 1px solid rgba(250,204,21,.4); }
.shop-coins i { font-style: normal; margin-right: .35rem; }
.shop-timer { font-size: .65rem; font-weight: 700; color: #9ca3af; margin-top: .2rem; }
.shop-layout { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 25rem; }
.shop-grid-wrap { overflow-y: auto; padding: 1rem 1.25rem; }
.shop-preview { overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: .8rem; border-left: 1px solid rgba(75,85,99,.45); background: rgba(0,0,0,.2); }
.shop-sect { display: flex; align-items: baseline; gap: .75rem; margin: .4rem 0 .7rem; }
.shop-sect h3 { font-size: .75rem; font-weight: 900; text-transform: uppercase; letter-spacing: .2em; color: #fbbf24; white-space: nowrap; }
.shop-sect small { font-size: .65rem; color: #6b7280; }
.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(9.2rem, 1fr)); gap: .75rem; margin-bottom: 1.2rem; }
.shop-tile { position: relative; display: flex; flex-direction: column; align-items: center; gap: .5rem; padding: .8rem .6rem .7rem; border-radius: 1.1rem; text-align: center; background: linear-gradient(180deg, rgba(31,41,55,.75), rgba(17,24,39,.85)); border: 2px solid rgba(75,85,99,.45); --rc: #6b7280; overflow: hidden; }
.shop-tile::before { content: ''; position: absolute; inset: 0; background: radial-gradient(circle at 50% 35%, color-mix(in srgb, var(--rc) 28%, transparent), transparent 65%); pointer-events: none; }
.shop-tile:hover { transform: translateY(-3px); border-color: var(--rc); }
.shop-tile.sel { border-color: var(--rc); box-shadow: 0 0 0 2px var(--rc), 0 10px 28px color-mix(in srgb, var(--rc) 45%, transparent); }
.shop-tile.r0 { --rc: #9ca3af; } .shop-tile.r1 { --rc: #60a5fa; } .shop-tile.r2 { --rc: #a78bfa; } .shop-tile.r3 { --rc: #f472b6; } .shop-tile.r4 { --rc: #fbbf24; }
.shop-tile .art { position: relative; height: 5.2rem; display: flex; align-items: center; justify-content: center; width: 100%; }
.shop-tile .nm { position: relative; font-size: .8rem; font-weight: 900; color: #fff; }
.tag { position: relative; font-size: .68rem; font-weight: 900; padding: .22rem .7rem; border-radius: 99px; }
.tag.price { color: #1c1002; background: linear-gradient(135deg, #fde047, #f59e0b); }
.tag.price.poor { background: rgba(31,41,55,.9); color: #f87171; border: 1px solid rgba(239,68,68,.5); }
.tag.own { color: #d1d5db; background: rgba(55,65,81,.8); }
.tag.eq { color: #6ee7b7; background: rgba(6,78,59,.7); border: 1px solid #059669; }
.shop-mini-table { width: 7rem; height: 4.4rem; border-radius: .8rem; border: 3px solid; display: flex; align-items: center; justify-content: center; font-size: 1.9rem; }
.shop-host-btn { width: 100%; margin-bottom: .75rem; padding: .7rem; border-radius: .9rem; font-size: .75rem; font-weight: 900; color: #d1d5db; background: rgba(17,24,39,.8); border: 1px solid rgba(75,85,99,.6); }
.shop-host-btn.on { color: #6ee7b7; border-color: #059669; }
/* preview */
.shop-scene { position: relative; isolation: isolate; overflow: hidden; border-radius: 1.2rem; border: 4px solid; min-height: 13rem; display: flex; align-items: center; justify-content: center; padding: 1.4rem .6rem; transition: box-shadow .3s; }
.shop-scene::after { content: ''; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(ellipse at 50% 40%, transparent 40%, rgba(0,0,0,.45)); }
.dice-preview.rack { display: flex; flex-wrap: wrap; justify-content: center; gap: .6rem; }
.dice-preview .dice { width: 56px; height: 56px; }
.dice-preview .dice-face { padding: 6px; border-radius: 13px; }
.dice-preview .pip { width: 9px; height: 9px; }
.shop-tile .dice-preview .dice { width: 62px; height: 62px; }
.shop-tile .dice-preview .dice { transform: rotate(-8deg); }
.shop-tile:hover .dice-preview .dice { transform: rotate(6deg) scale(1.1); }
.shop-pbar { display: flex; align-items: center; justify-content: space-between; gap: .5rem; flex-wrap: wrap; }
.shop-tswitch { display: flex; align-items: center; border-radius: .8rem; overflow: hidden; border: 1px solid rgba(75,85,99,.6); background: rgba(0,0,0,.3); }
.shop-tswitch button { width: 2rem; align-self: stretch; font-size: 1.2rem; font-weight: 900; color: #fbbf24; background: rgba(31,41,55,.8); }
.shop-tswitch span { padding: .4rem .7rem; font-size: .7rem; font-weight: 800; color: #e5e7eb; }
.shop-info { display: flex; flex-direction: column; gap: .7rem; padding: .9rem; border-radius: 1rem; background: rgba(31,41,55,.5); border: 1px solid rgba(75,85,99,.4); }
.shop-info h3 { font-size: 1.4rem; font-weight: 900; color: #fff; line-height: 1.2; }
.shop-info .act { display: flex; flex-direction: column; gap: .4rem; }
.shop-info .act .gm-btn { width: 100%; padding: .8rem; font-size: .85rem; }
.need { text-align: center; font-size: .7rem; font-weight: 700; color: #f87171; }
.rar { font-size: .62rem; font-weight: 900; text-transform: uppercase; letter-spacing: .2em; }
.rar.r0 { color: #9ca3af; } .rar.r1 { color: #60a5fa; } .rar.r2 { color: #a78bfa; } .rar.r3 { color: #f472b6; } .rar.r4 { color: #fbbf24; }
.shop-hint { font-size: .65rem; color: #6b7280; text-align: center; }

@media (max-width: 800px) {
    .gm-overlay { padding: 0; }
    .gm-window { border-radius: 0; height: 100%; max-height: 100%; }
    .gm-head { flex-wrap: wrap; gap: .5rem .75rem; padding: .7rem .9rem; }
    .shop-tabs { order: 5; width: 100%; } .shop-tabs button { flex: 1; }
    .shop-meta { margin-left: auto; }
    .shop-layout { display: flex; flex-direction: column; overflow-y: auto; }
    .shop-preview { order: -1; overflow: visible; border-left: 0; border-bottom: 1px solid rgba(75,85,99,.45); }
    .shop-grid-wrap { overflow: visible; }
    .set-layout { flex-direction: column; }
    .set-nav { width: auto; flex-direction: row; overflow-x: auto; border-right: 0; border-bottom: 1px solid rgba(75,85,99,.45); padding: .5rem; }
    .set-nav button { flex-shrink: 0; padding: .55rem .75rem; } .set-nav button span { font-size: .7rem; }
    .set-pages { padding: 1rem; }
    .set-row { flex-direction: column; align-items: stretch; gap: .7rem; }
    label.set-row { flex-direction: row; align-items: center; }
    .set-slider, .gm-step { width: 100%; }
}
html[data-gfx="mid"] .gm-overlay, html[data-gfx="low"] .gm-overlay { backdrop-filter: none; -webkit-backdrop-filter: none; background: rgba(3,1,5,.96); }
html[data-gfx="low"] .gm-window, html[data-gfx="low"] .shop-tile { animation: none; box-shadow: none; }

/* button reset (independent of Tailwind preflight) */
:where(.gm-window) button { background: transparent; border: 0; color: inherit; font: inherit; cursor: pointer; padding: 0; }
:where(.gm-window) button:disabled { cursor: not-allowed; }
.gm-close, .gm-btn, .shop-host-btn { border: 1px solid rgba(75,85,99,.6); }
.shop-tile { border: 2px solid rgba(75,85,99,.45); }
.shop-tile:hover, .shop-tile.sel { border-color: var(--rc); }
.gm-btn.primary { border-color: #ef4444; } .gm-btn.buy { border-color: #fcd34d; } .gm-btn.eq { border-color: #059669; }
.gm-btn.ghost { background: transparent; }
.gm-btn { background: rgba(31,41,55,.85); }
.gm-btn.primary { background: linear-gradient(135deg, #dc2626, #991b1b); }
.gm-btn.buy { background: linear-gradient(135deg, #f59e0b, #b45309); }
.gm-btn.eq { background: rgba(6,78,59,.55); }
.gm-btn.buy:disabled { background: rgba(31,41,55,.85); border-color: rgba(75,85,99,.6); }
.shop-host-btn { background: rgba(17,24,39,.8); }
.gm-close { background: rgba(31,41,55,.85); }
.gm-step button, .shop-tswitch button { background: rgba(31,41,55,.8); }
.set-nav button.on { background: linear-gradient(90deg, rgba(220,38,38,.45), rgba(220,38,38,.1)); border: 1px solid rgba(239,68,68,.6); }
.gm-seg button.on, .shop-tabs button.on { background: linear-gradient(135deg, #fbbf24, #f59e0b); }
html .dice-preview[data-skin] .pip { font-size: .72rem !important; }
html .shop-tile .dice-preview[data-skin] .pip { font-size: .85rem !important; }
.dice-preview[data-skin] .dice::after { font-size: .85rem; }
@media (max-width: 800px) {
    .gm-foot { padding: .6rem .75rem; gap: .5rem; }
    .gm-foot .gm-btn { padding: .6rem .7rem; font-size: .68rem; letter-spacing: .06em; }
    .gm-foot .gm-btn.primary { flex-shrink: 0; }
}
