:root {
  color-scheme: dark;
  --background: #080b14;
  --panel: #121829;
  --panel-light: #1a2238;
  --remote: #17191f;
  --key: #23262e;
  --key-edge: #343842;
  --text: #f4f7ff;
  --muted: #a8b2ca;
  --accent: #65d6ff;
  --success: #70e1a2;
  --danger: #ff6b6b;
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at top right, #1e3559 0, var(--background) 45%);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", sans-serif;
}
button, input, select { font: inherit; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
[hidden] { display: none !important; }

.remote-shell { margin: auto; max-width: 460px; padding: 20px 16px 32px; }
.topbar { align-items: center; display: flex; gap: 12px; justify-content: space-between; margin-bottom: 18px; }
.topbar-right { align-items: center; display: flex; gap: 10px; }
.eyebrow { color: var(--accent); font-size: .75rem; font-weight: 800; letter-spacing: .18em; margin: 0; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: 1.6rem; margin-bottom: 0; }
h2 { font-size: 1.2rem; margin-bottom: 12px; }
h3 { color: var(--accent); font-size: 1rem; margin: 18px 0 6px; }
.status { border: 1px solid; border-radius: 999px; font-size: .8rem; padding: 5px 11px; white-space: nowrap; }
.status-offline { border-color: #66718b; color: var(--muted); }
.status-online { border-color: var(--success); color: var(--success); }
.screen-message { color: var(--muted); }

.panel { background: rgba(18, 24, 41, .9); border: 1px solid #29334d; border-radius: 18px; margin-bottom: 16px; padding: 20px; }
.menu-button { background: var(--panel-light); border: 1px solid #3b496d; border-radius: 12px; color: var(--text); cursor: pointer; font-size: 1.3rem; height: 42px; width: 42px; }
.menu-panel { display: grid; gap: 6px; padding: 10px; }
.menu-item { background: transparent; border: 0; border-radius: 10px; color: var(--text); cursor: pointer; display: block; padding: 12px; text-align: left; text-decoration: none; }
.menu-item:hover { background: var(--panel-light); }
.menu-item-danger { color: var(--danger); }
.link-button { background: none; border: 0; color: var(--accent); cursor: pointer; display: inline-block; margin-top: 12px; padding: 0; text-decoration: underline; }

.pair-form { display: flex; gap: 10px; }
.pair-input, .text-input { background: #05070d; border: 1px solid #3b496d; border-radius: 12px; color: var(--text); min-width: 0; padding: 10px 14px; }
.pair-input { flex: 1; font-size: 1.5rem; letter-spacing: .15em; text-align: center; }
.pair-error { color: var(--danger); margin: 12px 0 0; min-height: 1.5em; }
.setup-form { display: grid; gap: 14px; margin-top: 16px; }
.setup-form label { color: var(--muted); display: grid; font-size: .9rem; gap: 6px; }
.install-panel ol { color: var(--muted); padding-left: 20px; }
.install-panel li { margin-bottom: 6px; }
.install-panel a { color: var(--accent); }
.control-button { background: var(--panel-light); border: 1px solid #3b496d; border-radius: 12px; color: var(--text); cursor: pointer; font-weight: 700; min-height: 50px; padding: 10px 18px; }
.control-button-primary { background: #215476; border-color: var(--accent); }

/* Chọn TV + khung trạng thái */
.tv-picker { align-items: center; display: flex; gap: 10px; margin-bottom: 12px; }
.tv-picker span { color: var(--muted); font-size: .85rem; white-space: nowrap; }
.tv-picker select { background: var(--panel-light); border: 1px solid #3b496d; border-radius: 10px; color: var(--text); flex: 1; min-width: 0; padding: 9px 10px; }
.tv-frame { background: #000; border: 8px solid #1c1f26; border-radius: 14px; box-shadow: 0 12px 30px rgba(0, 0, 0, .45); margin: 0 auto 22px; position: relative; }
.tv-frame::after { background: #1c1f26; border-radius: 0 0 6px 6px; bottom: -16px; content: ""; height: 8px; left: 40%; position: absolute; width: 20%; }
.tv-screen { aspect-ratio: 16 / 9; background: radial-gradient(circle at 30% 20%, #16314f, #05070d 70%); display: flex; flex-direction: column; justify-content: center; padding: 16px 20px; }
.tv-name { font-size: 1.25rem; font-weight: 800; margin-bottom: 2px; }
.tv-power { font-size: .9rem; font-weight: 700; margin-bottom: 4px; }
.tv-power-on { color: var(--success); }
.tv-power-off { color: var(--muted); }
.tv-source { color: #c9d3e8; font-size: .85rem; min-height: 1.3em; margin-bottom: 8px; }
.tv-volume { align-items: center; display: flex; font-size: .85rem; gap: 8px; }
.volume-bar { background: #26304a; border-radius: 99px; flex: 1; height: 6px; overflow: hidden; }
.volume-bar div { background: var(--accent); height: 100%; transition: width .3s ease; width: 0; }

/* Remote: bố cục theo remote Samsung thật */
.remote { background: linear-gradient(180deg, #1d2027, var(--remote)); border: 1px solid #2a2e37; border-radius: 40px; box-shadow: inset 0 1px 0 #2f333d, 0 18px 40px rgba(0, 0, 0, .5); margin: 0 auto; max-width: 330px; padding: 26px 22px 30px; }
.remote button { background: var(--key); border: 1px solid var(--key-edge); color: var(--text); cursor: pointer; transition: transform .08s ease, filter .15s ease; }
.remote button:active { filter: brightness(1.5); transform: scale(.94); }
.remote button:disabled, .unsupported { cursor: not-allowed; opacity: .3; }
.remote-row { display: flex; justify-content: space-between; margin: 0 6px 22px; }
.round-button { align-items: center; border-radius: 50%; display: flex; flex-direction: column; font-size: 1.3rem; height: 62px; justify-content: center; line-height: 1; width: 62px; }
.round-button small { color: var(--muted); font-size: .6rem; margin-top: 4px; }
.remote .power-button { background: #c62f3a; border-color: #e0525c; font-size: 1.5rem; }
.input-list { display: flex; flex-wrap: wrap; gap: 8px; justify-content: center; margin: -8px 0 20px; }
.remote .input-chip { border-radius: 99px; font-size: .85rem; padding: 7px 14px; }
.remote .input-chip-active { background: #215476; border-color: var(--accent); }
.dpad { aspect-ratio: 1; background: var(--key); border: 1px solid var(--key-edge); border-radius: 50%; display: grid; grid-template-areas: ". up ." "left ok right" ". down ."; grid-template-columns: 1fr 1.3fr 1fr; grid-template-rows: 1fr 1.3fr 1fr; margin: 0 auto 24px; width: 230px; }
.remote .dpad > button { background: transparent; border: 0; border-radius: 50%; color: var(--muted); font-size: 1.1rem; }
.remote .dpad-up { grid-area: up; }
.remote .dpad-left { grid-area: left; }
.remote .dpad-right { grid-area: right; }
.remote .dpad-down { grid-area: down; }
.remote .dpad > .dpad-ok { background: #121419; border: 1px solid var(--key-edge); color: var(--text); font-weight: 800; grid-area: ok; margin: 6px; }
.rockers { display: grid; gap: 22px; grid-template-columns: 1fr 1fr; margin: 0 6px 26px; }
.rocker { align-items: center; background: #c9ccd3; border-radius: 16px; display: flex; flex-direction: column; overflow: hidden; }
.remote .rocker button { background: #dfe2e8; border: 0; border-radius: 0; color: #20232a; font-size: 1.4rem; font-weight: 800; height: 52px; width: 100%; }
.rocker span { color: #20232a; font-size: .75rem; font-weight: 800; letter-spacing: .1em; padding: 4px 0; }
.app-row { gap: 10px; margin-bottom: 0; }
.remote .app-pill { border-radius: 99px; flex: 1; font-size: .75rem; font-weight: 800; height: 44px; padding: 0 6px; }
.remote .app-netflix { color: #e50914; }
.remote .app-prime { color: #00a8e1; }
.remote .app-youtube { color: #ff4e45; }

@media (max-width: 360px) {
  .round-button { height: 54px; width: 54px; }
  .dpad { width: 200px; }
}
