:root {
--bg: #272727;
--panel: #222222;
--panel-2: #1c1c1c;
--accent: #1976d2;
--accent-dim: #194692;
--text: #D9D9D9;
--muted: #999999;
--bad: #f87171;
--good: #1976d2;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; }
body {
margin: 0;
min-height: 100vh;
display: flex;
align-items: flex-start;
justify-content: center;
background: var(--bg);
font-family: 'Inter', 'Segoe UI', sans-serif;
color: var(--text);
padding: 28px 14px;
font-size: 16px;
}

.stage { width: 100%; max-width: 820px; }

h1 {
font-size: 20px;
font-weight: 700;
margin: 0 0 22px;
color: var(--muted);
text-align: center;
max-height: 60px;
overflow: hidden;
transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
}
h1.hidden {
	opacity: 0; 
	max-height: 0;
	margin: 0;
}

.layout {
display: flex;
align-items: stretch;
gap: 12px;
min-height: 60px;
}

/* ---- Mode select column ---- */
.mode-panel {
display: flex;
flex-direction: column;
gap: 12px;
width: 220px;
flex: 0 0 220px;
transition: width 0.45s cubic-bezier(.4,0,.2,1),
			flex-basis 0.45s cubic-bezier(.4,0,.2,1),
			transform 0.45s cubic-bezier(.4,0,.2,1);
transform: translateX(0);
}
.mode-panel.revealed { width: 64px; flex-basis: 64px; }

.mode-btn {
background: var(--panel);
border: 1px solid #333333;
border-radius: 12px;
padding: 18px 16px;
font-size: 17px;
font-weight: 700;
color: var(--text);
cursor: pointer;
text-align: left;
transition: padding 0.4s ease, border-color 0.2s ease, background 0.2s ease;
white-space: nowrap;
overflow: hidden;
min-height: 56px;
touch-action: manipulation;
}
.mode-btn:active, .mode-btn:hover { border-color: var(--accent); }
.mode-btn .sub { display: block; font-size: 12px; font-weight: 400; color: var(--muted); margin-top: 3px; }

.mode-panel.revealed .mode-btn {
padding: 16px 0;
text-align: center;
}
.mode-panel.revealed .mode-btn .full { display: none; }
.mode-panel.revealed .mode-btn .short { display: block; }
.mode-btn .short { display: none; font-size: 14px; }
.mode-btn.active { border-color: var(--accent); background: var(--accent-dim); }

.back-btn {
margin-top: 4px;
background: none;
border: none;
color: var(--muted);
font-size: 13px;
cursor: pointer;
text-decoration: underline;
padding: 10px 0;
display: none;
min-height: 44px;
touch-action: manipulation;
}
.mode-panel.revealed .back-btn { display: block; text-decoration: none; font-size: 22px; }

/* ---- Game panel (revealed area) ---- */
.game-panel {
flex: 0 0 0;
width: 0;
opacity: 0;
overflow: hidden;
transition: flex-basis 0.45s cubic-bezier(.4,0,.2,1), width 0.45s cubic-bezier(.4,0,.2,1), opacity 0.35s ease 0.1s;
background: var(--panel);
border: 1px solid #333333;
border-radius: 12px;
}
.game-panel.revealed {
flex: 1 1 auto;
width: auto;
opacity: 1;
padding: 18px 14px;
min-width: 0;
}

.game-title {
font-size: 18px;
font-weight: 800;
margin: 0 0 16px;
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 6px;
}
.game-title .status { font-size: 13px; font-weight: 600; color: var(--accent); }

.player-name {
background: none;
border: none;
border-bottom: 2px dashed #444444;
color: var(--text);
font-size: 16px;
font-weight: 700;
width: 100%;
padding: 8px 2px;
}
.player-name:focus { outline: none; border-color: var(--accent); }

/* Cricket grid */
table.cricket { width: 100%; border-collapse: collapse; font-size: 15px; table-layout: fixed; }
table.cricket th, table.cricket td {
padding: 6px 4px;
text-align: center;
border-bottom: 1px solid #333333;
}
table.cricket th:first-child, table.cricket td:first-child { text-align: left; width: 44px; color: var(--muted); font-weight: 700; }
.mark-cell {
cursor: pointer;
border-radius: 10px;
background: var(--panel-2);
user-select: none;
-webkit-touch-callout: none;
transition: background 0.15s ease;
font-weight: 800;
letter-spacing: 2px;
font-size: 20px;
min-height: 52px;
display: flex;
align-items: center;
justify-content: center;
touch-action: manipulation;
}
.mark-cell:active, .mark-cell:hover { background: #2a2a2a; }
.mark-cell.closed { color: var(--accent); }
.mark-cell.flash-decrement { background: var(--bad) !important; color: #fff !important; }

.controls-row {
display: flex;
gap: 10px;
align-items: center;
margin-top: 18px;
flex-wrap: wrap;
}
.mult-group { display: flex; gap: 8px; flex: 1 1 auto; min-width: 0; }
.mult-btn {
background: var(--panel-2);
border: 1px solid #333333;
color: var(--text);
border-radius: 8px;
padding: 12px 10px;
font-size: 14px;
font-weight: 700;
cursor: pointer;
flex: 1;
min-height: 46px;
touch-action: manipulation;
}
.mult-btn.active { background: var(--accent); color: #ffffff; border-color: var(--accent); }

.dart-dots { display: flex; gap: 6px; order: 3; width: 100%; justify-content: center; margin-top: 4px; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #444444; }
.dot.used { background: var(--accent); }

.end-turn-btn, .action-btn {
background: var(--panel-2);
border: 1px solid #333333;
color: var(--text);
border-radius: 8px;
padding: 12px 16px;
font-size: 14px;
font-weight: 700;
cursor: pointer;
min-height: 46px;
touch-action: manipulation;
flex: 1 1 auto;
}
.end-turn-btn:active, .action-btn:active, .end-turn-btn:hover, .action-btn:hover { border-color: var(--accent); }

.score-tally { display: flex; gap: 24px; margin-top: 16px; }
.score-tally .player-score { font-size: 30px; font-weight: 900; }
.score-tally .label { font-size: 13px; color: var(--muted); font-weight: 600; }

/* X01 layout */
.x01-players { display: flex; gap: 12px; margin-bottom: 16px; }
.x01-card {
flex: 1;
background: var(--panel-2);
border: 1px solid #333333;
border-radius: 12px;
padding: 16px 12px;
min-width: 0;
}
.x01-card .remaining { font-size: 40px; font-weight: 900; margin: 8px 0; }
.x01-card.winner { border-color: var(--accent); }
.x01-card .winner-tag { color: var(--accent); font-size: 13px; font-weight: 800; }

.x01-input-row { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.x01-input-row input {
width: 100px;
background: var(--panel);
border: 1px solid #333333;
border-radius: 8px;
color: var(--text);
padding: 12px;
font-size: 16px;
min-height: 46px;
}
.quick-scores { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.quick-scores button {
background: var(--panel-2);
border: 1px solid #333333;
color: var(--text);
border-radius: 8px;
padding: 10px 14px;
font-size: 15px;
font-weight: 700;
cursor: pointer;
min-height: 44px;
min-width: 52px;
touch-action: manipulation;
}
.quick-scores button:active, .quick-scores button:hover { border-color: var(--accent); }

.history { margin-top: 16px; font-size: 13px; color: var(--muted); max-height: 130px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.history div { padding: 6px 0; border-bottom: 1px solid #2a2a2a; }
.history .bust { color: var(--bad); }

/* ---- Mobile tweaks ---- */
@media (max-width: 620px) {
body { padding: 14px 12px; font-size: 17px; }
h1 { font-size: 19px; margin-bottom: 18px; }
.layout { gap: 8px; }
.mode-panel { width: 190px; flex-basis: 190px; gap: 12px; }
.mode-panel.revealed { width: 60px; flex-basis: 60px; }
.mode-btn { padding: 20px 14px; font-size: 18px; min-height: 64px; border-radius: 14px; }
.mode-btn .sub { font-size: 13px; }
.mode-panel.revealed .mode-btn { padding: 16px 0; margin-left: 12px; }
.back-btn { font-size: 26px; min-height: 48px; }
.game-panel.revealed { padding: 16px 12px; margin-right: 14px; }
.game-title { font-size: 19px; margin-bottom: 14px; }
.game-title .status { font-size: 14px; }
.player-name { font-size: 18px; padding: 10px 2px; }
table.cricket { font-size: 16px; }
table.cricket th, table.cricket td { padding: 6px 3px; }
table.cricket th:first-child, table.cricket td:first-child { width: 42px; font-size: 14px; }
.mark-cell { font-size: 22px; min-height: 58px; border-radius: 10px; }
.score-tally { gap: 20px; margin-top: 18px; }
.score-tally .player-score { font-size: 32px; }
.score-tally .label { font-size: 14px; }
.x01-card { padding: 16px 10px; }
.x01-card .remaining { font-size: 38px; }
.x01-players { gap: 8px; }
.controls-row { gap: 10px; margin-top: 20px; }
.mult-btn { padding: 15px 8px; font-size: 15px; min-height: 52px; border-radius: 10px; }
.end-turn-btn, .action-btn { padding: 15px 12px; font-size: 15px; min-height: 52px; border-radius: 10px; }
.quick-scores { gap: 10px; margin-top: 14px; }
.quick-scores button { padding: 13px 12px; font-size: 17px; min-width: 54px; min-height: 50px; border-radius: 10px; }
.x01-input-row input { width: 110px; font-size: 18px; padding: 14px; min-height: 52px; border-radius: 10px; }
.x01-input-row button { min-height: 52px; }
.history { font-size: 14px; max-height: 150px; }
}

@media (max-width: 380px) {
.mode-panel { width: 165px; flex-basis: 165px; }
.mode-btn { font-size: 15px; padding: 18px 10px; min-height: 58px; }
.mode-btn .sub { display: none; }
}