* { box-sizing: border-box; margin: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #120c08; color: #fff; font-family: system-ui, -apple-system, "Segoe UI", "DejaVu Sans", sans-serif; -webkit-user-select: none; user-select: none; }
#stage { position: absolute; inset: 0; }
#stage canvas { position: absolute; inset: 0; touch-action: none; }
.ui { position: absolute; inset: 0; pointer-events: none; padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left); }
.ui > * { pointer-events: auto; }
.ui > .hint, .ui > .toast, .ui > .name p { pointer-events: none; }

.glass { background: rgba(14, 12, 10, .42); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px); border: 1px solid rgba(255, 255, 255, .12); border-radius: 16px; }
button, select, input { font: inherit; color: inherit; }
button { background: rgba(255, 255, 255, .1); border: 0; border-radius: 10px; min-height: 44px; min-width: 44px; padding: 0 14px; cursor: pointer; }
button:hover { background: rgba(255, 255, 255, .18); }
button:focus-visible, select:focus-visible, input:focus-visible { outline: 2px solid #ffd9a0; outline-offset: 2px; }
kbd { font-family: inherit; font-size: 12px; padding: 2px 6px; border-radius: 5px; border: 1px solid rgba(255, 255, 255, .45); }

.name { position: absolute; top: calc(28px + env(safe-area-inset-top)); left: calc(36px + env(safe-area-inset-left)); text-shadow: 0 2px 12px rgba(0, 0, 0, .5); }
.name input { background: transparent; border: 0; border-bottom: 1px dashed transparent; font-family: Georgia, "DejaVu Serif", serif; font-size: 40px; width: 12em; padding: 0; color: #fff; text-shadow: inherit; }
.name input:hover, .name input:focus { border-bottom-color: rgba(255, 255, 255, .35); outline: none; }
.name p { font-size: 14px; opacity: .8; margin-top: 4px; letter-spacing: 1px; text-transform: uppercase; }

.stats { position: absolute; top: calc(28px + env(safe-area-inset-top)); right: calc(36px + env(safe-area-inset-right)); width: 260px; padding: 18px 20px; font-size: 13px; }
.stat { margin-bottom: 11px; }
.stat .l { display: flex; justify-content: space-between; opacity: .85; margin-bottom: 5px; }
.stat .t { height: 5px; border-radius: 3px; background: rgba(255, 255, 255, .14); overflow: hidden; }
.stat .t i { display: block; height: 100%; border-radius: 3px; background: linear-gradient(90deg, #ffd9a0, #ffb35c); transition: width .25s; }
.sep { height: 1px; background: rgba(255, 255, 255, .12); margin: 14px 0 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font-size: 12px; padding: 4px 9px; border-radius: 20px; background: rgba(255, 255, 255, .12); }
.vs { font-size: 12px; margin-top: 10px; }
.vs div { display: flex; justify-content: space-between; padding: 2px 0; opacity: .9; }
.vs b { font-weight: 600; }
.vs .good { color: #ffd9a0; }
.vs .bad { opacity: .55; }

.left { position: absolute; left: calc(36px + env(safe-area-inset-left)); bottom: calc(28px + env(safe-area-inset-bottom)); display: flex; gap: 6px; padding: 8px; }
.left select { background: rgba(255, 255, 255, .1); border: 0; border-radius: 10px; min-height: 44px; padding: 0 10px; font-size: 16px; }
.left select option { color: #000; }

.mats { position: absolute; bottom: calc(28px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px; }
.mat { width: 66px; height: 66px; border-radius: 11px; display: flex; flex-direction: column; align-items: center; justify-content: center; font-size: 11px; position: relative; opacity: .75; padding: 0; background: transparent; }
.mat.sel { background: rgba(255, 255, 255, .16); opacity: 1; box-shadow: inset 0 0 0 1.5px rgba(255, 217, 160, .85); }
.mat .sw { width: 26px; height: 26px; border-radius: 6px; margin-bottom: 5px; }
.mat .k { position: absolute; top: 4px; left: 7px; font-size: 10px; opacity: .6; }

.layer { position: absolute; bottom: calc(112px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 6px; padding: 6px; font-size: 13px; }
.layer span { min-width: 64px; text-align: center; opacity: .85; }
.layer .mode { margin-left: 8px; }
.layer .mode.remove { background: rgba(255, 90, 74, .35); }

.swings { position: absolute; right: calc(36px + env(safe-area-inset-right)); bottom: calc(28px + env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: flex-end; }
.swings button { padding: 0 16px; font-size: 14px; }

.hint { position: absolute; left: 50%; transform: translateX(-50%); bottom: calc(168px + env(safe-area-inset-bottom)); font-size: 13px; opacity: .7; text-shadow: 0 1px 6px rgba(0, 0, 0, .7); white-space: nowrap; }
.toast { position: absolute; left: 50%; top: 40%; transform: translateX(-50%); background: rgba(14, 12, 10, .75); padding: 10px 16px; border-radius: 12px; font-size: 14px; opacity: 0; transition: opacity .2s; }
.toast.on { opacity: 1; }
.install { position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); background: rgba(14, 12, 10, .8); padding: 4px 4px 4px 14px; border-radius: 12px; font-size: 14px; display: flex; align-items: center; gap: 8px; }

@media (max-width: 760px) {
  .name input { font-size: 26px; width: 9em; }
  .stats { width: 200px; padding: 12px 14px; font-size: 12px; top: auto; bottom: calc(190px + env(safe-area-inset-bottom)); right: 10px; }
  .left { left: 10px; bottom: calc(100px + env(safe-area-inset-bottom)); }
  .mats { bottom: calc(14px + env(safe-area-inset-bottom)); }
  .mat { width: 58px; height: 58px; }
  .layer { bottom: calc(160px + env(safe-area-inset-bottom)); left: 10px; transform: none; }
  .swings { right: 10px; bottom: calc(100px + env(safe-area-inset-bottom)); }
  .swings kbd { display: none; }
  .hint { display: none; }
}
/* Short screens (phones in landscape) */
@media (max-height: 520px) {
  .name { top: calc(8px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left)); }
  .name input { font-size: 24px; width: 9em; }
  .name p { font-size: 11px; }
  .stats { top: calc(8px + env(safe-area-inset-top)); right: calc(8px + env(safe-area-inset-right)); bottom: auto; width: 196px; padding: 10px 12px; font-size: 11px; }
  .stat { margin-bottom: 5px; }
  .stat .l { margin-bottom: 3px; }
  .sep { margin: 7px 0 6px; }
  .chip { font-size: 10px; padding: 2px 7px; }
  .vs { margin-top: 5px; font-size: 11px; }
  .vs div { padding: 0; }
  .layer { top: calc(72px + env(safe-area-inset-top)); bottom: auto; left: calc(12px + env(safe-area-inset-left)); transform: none; padding: 4px; }
  .layer span { min-width: 54px; font-size: 12px; }
  .left { left: calc(12px + env(safe-area-inset-left)); bottom: calc(84px + env(safe-area-inset-bottom)); padding: 4px; }
  .mats { bottom: calc(8px + env(safe-area-inset-bottom)); padding: 4px; }
  .mat { width: 58px; height: 58px; }
  .swings { flex-direction: row; right: calc(8px + env(safe-area-inset-right)); bottom: calc(8px + env(safe-area-inset-bottom)); }
  .swings button { padding: 0 12px; font-size: 13px; }
  .swings kbd { display: none; }
  .hint { display: none; }
}
@media (prefers-color-scheme: light) { html, body { background: #120c08; } }
.install[hidden] { display: none; }
