:root {
  --bg-primary: #0a0c0f; --bg-panel: #15181c; --bg-card-hover: #1b1f25; --bg-icon-well: #1f2328;
  --accent: #6ec69c; --accent-hover: #88d8b0; --accent-gold: #d0a85f; --accent-danger: #e16f6f; --accent-blue: #7fb8d6;
  --text-primary: #e6e8eb; --text-secondary: #7e848c; --text-dim: #5a6068; --border-color: #22262c;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg-primary); color: var(--text-primary); font: 15px/1.45 Figtree, system-ui, sans-serif; }
h1, h2 { margin: 0; font-family: Tektur, Figtree, sans-serif; font-weight: 600; }
h1 { font-size: 26px; } h2 { font-size: 20px; }
.dim { color: var(--text-secondary); } .small { font-size: 13px; } .nowrap { white-space: nowrap; }
.gain { color: var(--accent); } .loss { color: var(--accent-danger); }
.error { color: var(--accent-danger); min-height: 1em; margin: 8px 0 0; }
.card { background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 12px; padding: 24px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { min-height: 44px; padding: 0 18px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-icon-well); cursor: pointer; transition: background .15s ease, border-color .15s ease; }
button:hover { background: var(--bg-card-hover); border-color: #2f343b; }
button.primary { background: var(--accent); border-color: var(--accent); color: #0a0c0f; font-weight: 600; }
button.primary:hover { background: var(--accent-hover); }
button:disabled { opacity: .5; cursor: progress; }
button.icon { min-width: 44px; padding: 0; font-size: 20px; line-height: 1; background: transparent; border-color: transparent; color: var(--text-secondary); }
button.icon:hover { color: var(--text-primary); background: var(--bg-icon-well); }
button.delete:hover { color: var(--accent-danger); }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
input, select, textarea { width: 100%; min-height: 44px; margin-top: 4px; padding: 8px 12px; border-radius: 8px; border: 1px solid var(--border-color); background: var(--bg-primary); }
input:invalid:not(:placeholder-shown) { border-color: var(--accent-danger); }
label { display: block; font-size: 13px; color: var(--text-secondary); }

body.login { display: grid; place-items: center; min-height: 100vh; }
body.login form { width: min(340px, 90vw); display: grid; gap: 12px; }

header { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 24px 32px; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; background: rgba(10, 12, 15, .85); backdrop-filter: blur(12px); z-index: 2; }
header p { margin: 4px 0 0; }
main { padding: 24px 32px 48px; }
.empty { max-width: 460px; margin: 64px auto; text-align: center; }

.table-wrap { overflow-x: auto; border: 1px solid var(--border-color); border-radius: 12px; }
table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
th, td { padding: 10px 12px; text-align: left; vertical-align: middle; border-bottom: 1px solid var(--border-color); }
th { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-secondary); background: var(--bg-panel); white-space: nowrap; }
th .dim { text-transform: none; letter-spacing: 0; font-weight: 400; color: var(--text-dim); }
tbody tr:hover { background: var(--bg-panel); }
tbody tr:last-child td { border-bottom: 0; }
.num { text-align: right; white-space: nowrap; }
.mon { display: flex; align-items: center; gap: 8px; min-width: 180px; }
.mon img { image-rendering: pixelated; flex: none; }
.mon span { display: grid; } .mon small { font-size: 12px; }
.shot { margin-left: auto; font-size: 12px; color: var(--accent-blue); }
.gender { font-size: 18px; text-align: center; }
.gender.male { color: var(--accent-blue); } .gender.female { color: #e89ac7; }
.stats { display: inline-flex; gap: 2px; }
.stats span { min-width: 30px; padding: 2px 4px; text-align: center; border-radius: 4px; background: var(--bg-icon-well); font-size: 13px; }
.stats span.max { background: rgba(110, 198, 156, .15); color: var(--accent); font-weight: 600; }
.moves, .comment { min-width: 160px; font-size: 13px; }
.comment { max-width: 280px; color: var(--text-secondary); }

.tip { position: relative; border-bottom: 1px dotted var(--text-secondary); cursor: help; }
.tip:hover::after, .tip:focus::after { content: attr(data-tip); position: absolute; left: 0; top: calc(100% + 6px); z-index: 3; width: max-content; max-width: min(300px, 70vw); white-space: normal; font-weight: 400; text-transform: none; letter-spacing: 0; padding: 6px 10px; border-radius: 8px; background: var(--bg-icon-well); border: 1px solid var(--border-color); color: var(--text-primary); font-size: 13px; box-shadow: 0 8px 24px rgba(0, 0, 0, .4); }

.pager { display: flex; gap: 6px; justify-content: center; margin-top: 20px; }
.pager a { min-width: 44px; min-height: 44px; display: grid; place-items: center; border-radius: 8px; border: 1px solid var(--border-color); color: var(--text-primary); text-decoration: none; }
.pager a:hover { background: var(--bg-card-hover); }
.pager a[aria-current] { background: var(--accent); border-color: var(--accent); color: #0a0c0f; font-weight: 600; }

dialog { width: min(720px, 94vw); max-height: 92vh; padding: 0; border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-panel); color: var(--text-primary); }
dialog::backdrop { background: rgba(0, 0, 0, .6); backdrop-filter: blur(4px); }
dialog form { padding: 20px 24px 24px; }
.sheet-head, .sheet-foot { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.sheet-foot { justify-content: flex-end; margin-top: 16px; }
.drop { display: grid; place-items: center; min-height: 120px; margin-top: 16px; padding: 12px; border: 1px dashed #353a42; border-radius: 12px; text-align: center; cursor: pointer; transition: border-color .15s ease, background .15s ease; }
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(110, 198, 156, .06); }
.drop input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.drop img { max-height: 260px; max-width: 100%; border-radius: 8px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.grid .wide { grid-column: 1 / -1; }
/* Table wider than the screen (set by JS): each entry becomes a card whose cells wrap onto extra rows. */
.stacked { overflow: visible; border: 0; border-radius: 0; }
.stacked table, .stacked tbody { display: block; }
.stacked thead { display: none; }
.stacked tbody tr { position: relative; display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px 20px; margin-bottom: 10px; padding: 12px 56px 12px 14px; background: var(--bg-panel); border: 1px solid var(--border-color); border-radius: 12px; }
.stacked tbody tr:hover { background: var(--bg-card-hover); }
.stacked td { padding: 0; border: 0; flex: 0 1 auto; }
.stacked td[data-label]:not([data-label=""])::before { content: attr(data-label); display: block; margin-bottom: 2px; font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: var(--text-dim); }
.stacked td.mon { min-width: 0; }
.stacked td.mon .shot { margin-left: 8px; }
.stacked .num, .stacked .gender { text-align: left; }
.stacked .moves, .stacked .comment { min-width: 0; max-width: none; }
.stacked td.comment { flex: 1 1 200px; }
.stacked td.comment:empty { display: none; }
.stacked td:last-child { position: absolute; top: 6px; right: 6px; }
@media (max-width: 640px) { header, main { padding-left: 16px; padding-right: 16px; } }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; } }
