* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background: #071d25;
  color: #f5fbff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

body.dark-mode { background: #030507; color: #f4fafc; }

button, input, select, textarea { font: inherit; }

button {
  min-height: 42px;
  border: 1px solid #2fd2d8;
  border-radius: 12px;
  background: #123c49;
  color: #f5fbff;
  font-weight: 700;
  cursor: pointer;
  -webkit-appearance: none;
}

button:active { -webkit-transform: translateY(1px); transform: translateY(1px); }
button:focus, input:focus, select:focus, textarea:focus { outline: 2px solid rgba(47, 210, 216, .45); outline-offset: 1px; }

body.dark-mode button { background: #070b10; border-color: #1b3d49; color: #f4fafc; }
body.dark-mode button:focus { outline-color: rgba(30, 215, 229, .5); }

.primary, .tab.active { background: #30d2d9; color: #062128; border-color: #30d2d9; }
body.dark-mode .primary, body.dark-mode .tab.active { background: #1ed7e5; color: #031318; border-color: #1ed7e5; }
.wide { width: 100%; }

.app {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 12px 10px 30px;
}

.topbar {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  padding: 12px;
  border: 1px solid #2a6573;
  border-radius: 20px;
  background: #123c49;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .22);
}

body.dark-mode .topbar { background: #0a1016; border-color: #1b3d49; }

.brand { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; min-width: 0; }
.brand img { width: 150px; height: 64px; margin-right: 11px; object-fit: contain; border-radius: 14px; -webkit-flex: 0 0 auto; flex: 0 0 auto; }
.brand strong { display: block; font-size: 1.2rem; line-height: 1; letter-spacing: .03em; }
.brand span { display: block; color: #a9c4cb; font-size: .82rem; margin-top: 4px; }

.top-actions { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-flex-wrap: wrap; flex-wrap: wrap; }
.top-actions > * { margin-left: 7px; }

select, input, textarea {
  border: 1px solid #285765;
  border-radius: 11px;
  background: #092832;
  color: #f5fbff;
  padding: 10px 11px;
}

body.dark-mode select, body.dark-mode input, body.dark-mode textarea { background: #070b10; border-color: #1b3d49; color: #f4fafc; }

.theme-button { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; padding: 0 11px; }
.theme-button span:first-child { margin-right: 6px; font-size: 18px; line-height: 1; }
.icon-button { width: 42px; min-width: 42px; padding: 0; font-size: 1.2rem; }

.panel {
  margin: 12px 0;
  padding: 14px;
  border: 1px solid #2a6573;
  border-radius: 18px;
  background: #123c49;
  box-shadow: 0 8px 22px rgba(0, 0, 0, .12);
}

body.dark-mode .panel { background: #0a1016; border-color: #1b3d49; }
.section-title { color: #f7c83f; text-transform: uppercase; font-weight: 800; letter-spacing: .03em; margin-bottom: 10px; }

.ip-row { display: -webkit-flex; display: flex; }
.ip-row input { min-width: 0; -webkit-flex: 1 1 auto; flex: 1 1 auto; border-radius: 12px 0 0 12px; }
.ip-row button { border-radius: 0 12px 12px 0; margin-left: -1px; padding-left: 13px; padding-right: 13px; }
.check-row { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; color: #f5fbff; margin: 10px 0 2px; }
.check-row input { width: 18px; height: 18px; margin-right: 8px; padding: 0; accent-color: #2fd2d8; }

.tabs { display: -webkit-flex; display: flex; padding: 4px; border: 1px solid #2a6573; border-radius: 15px; background: #092832; margin: 12px 0; }
.tab { border: 0; border-radius: 11px; background: transparent; -webkit-flex: 1 1 0; flex: 1 1 0; margin: 0 2px; }
body.dark-mode .tabs { background: #070b10; border-color: #1b3d49; }
body.dark-mode .tab { background: transparent; }
.page { display: none; }
.page.active { display: block; }

textarea { width: 100%; min-height: 190px; resize: vertical; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; line-height: 1.45; }
.button-grid, .settings-grid { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 10px -4px; }
.button-grid > *, .settings-grid > * { -webkit-flex: 1 1 220px; flex: 1 1 220px; margin: 4px; }
.muted { color: #a9c4cb; }
body.dark-mode .muted { color: #8297a2; }
.search { width: 100%; margin-bottom: 10px; }
.cover-note { margin: 0 0 9px; color: #7fb2bd; font-size: .82rem; }
body.dark-mode .cover-note { color: #7895a0; }

.game-list { display: block; }
.game-card {
  width: 100%;
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  text-align: left;
  margin: 8px 0 0;
  padding: 9px;
  border: 1px solid #2a6573;
  border-radius: 15px;
  background: #0b303b;
}
.game-card:hover { border-color: #2fd2d8; }
body.dark-mode .game-card { background: #070b10; border-color: #1b3d49; }
body.dark-mode .game-card:hover { background: #12323e; border-color: #1ed7e5; }
.game-cover { width: 48px; height: 58px; margin-right: 10px; border-radius: 8px; overflow: hidden; background: #061820; border: 1px solid #2fd2d8; -webkit-flex: 0 0 auto; flex: 0 0 auto; }
.game-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.game-mark { width: 100%; height: 100%; display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; -webkit-justify-content: center; justify-content: center; color: #f7c83f; font-weight: 900; }
.game-copy { min-width: 0; }
.game-title { font-weight: 800; line-height: 1.2; }
.game-meta { margin-top: 4px; color: #a9c4cb; font-size: .84rem; }
.pill-row { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; -webkit-justify-content: flex-end; justify-content: flex-end; margin-left: auto; padding-left: 8px; }
.pill { border-radius: 999px; padding: 4px 8px; margin: 2px; background: #071d25; color: #f7c83f; font-size: .76rem; font-weight: 800; white-space: nowrap; }
#statusBox { min-height: 36px; white-space: pre-wrap; overflow-wrap: anywhere; }
.fallback { margin-top: 12px; border-top: 1px solid #2a6573; padding-top: 12px; max-height: 210px; overflow: auto; }
.fallback a { display: block; color: #f7c83f; margin: 6px 0; overflow-wrap: anywhere; }
.hidden { display: none; }

.mini-status { position: fixed; left: 10px; right: 10px; bottom: 10px; z-index: 30; max-width: 760px; margin: 0 auto; padding: 10px 12px; border: 1px solid #2fd2d8; border-radius: 13px; background: rgba(4, 18, 25, .95); color: #f5fbff; box-shadow: 0 8px 28px rgba(0, 0, 0, .35); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; pointer-events: none; }

.modal { position: fixed; left: 3%; right: 3%; top: 4%; z-index: 25; width: 94%; max-width: 820px; max-height: 90%; overflow: auto; margin: 0 auto; border: 1px solid #2fd2d8; border-radius: 20px; background: #071d25; color: #f5fbff; padding: 14px; box-shadow: 0 18px 60px rgba(0, 0, 0, .6); }
body.dark-mode .modal { background: #030507; border-color: #1ed7e5; }
.dialog-head { display: -webkit-flex; display: flex; -webkit-justify-content: space-between; justify-content: space-between; -webkit-align-items: flex-start; align-items: flex-start; border-bottom: 1px solid #2a6573; padding-bottom: 10px; }
.dialog-cover { width: 76px; height: 104px; margin-right: 12px; border-radius: 10px; overflow: hidden; background: #061820; border: 1px solid #2fd2d8; -webkit-flex: 0 0 auto; flex: 0 0 auto; }
.dialog-cover img { display: block; width: 100%; height: 100%; object-fit: cover; }
.dialog-head > div:nth-child(2) { min-width: 0; -webkit-flex: 1 1 auto; flex: 1 1 auto; }
.dialog-head h2 { margin: 0; line-height: 1.15; }
.dialog-actions { display: -webkit-flex; display: flex; -webkit-flex-wrap: wrap; flex-wrap: wrap; margin: 10px -4px; }
.dialog-actions > * { -webkit-flex: 1 1 180px; flex: 1 1 180px; margin: 4px; }
.patch-list { display: block; }
.patch-card { border: 1px solid #2a6573; border-radius: 15px; padding: 12px; margin-top: 9px; background: #092832; }
body.dark-mode .patch-card { background: #070b10; border-color: #1b3d49; }
.patch-card h3 { margin: 0 0 7px; color: #f7c83f; }
.patch-card p { margin: 8px 0; }
.patch-card pre { white-space: pre-wrap; overflow-wrap: anywhere; background: #041219; padding: 10px; border-radius: 9px; }
.settings-content img { width: 100%; max-width: 260px; background: #fff; border-radius: 12px; margin: 8px; }
.warning { border-color: #f7c83f; }
.clock-row { display: -webkit-flex; display: flex; -webkit-align-items: center; align-items: center; margin: 10px 0; }
.clock-row label { -webkit-flex: 1 1 auto; flex: 1 1 auto; }
.clock-row input { width: 120px; margin: 0 8px; }

@media (max-width: 680px) {
  .app { padding-left: 8px; padding-right: 8px; }
  .topbar { display: block; }
  .top-actions { margin-top: 12px; }
  .top-actions > * { margin-left: 0; margin-right: 6px; margin-top: 4px; }
  .top-actions select { -webkit-flex: 1 1 80px; flex: 1 1 80px; }
  .top-actions .theme-button { -webkit-flex: 1 1 140px; flex: 1 1 140px; }
  .game-card { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .pill-row { width: 100%; -webkit-justify-content: flex-start; justify-content: flex-start; padding-left: 58px; margin-top: 3px; }
  .clock-row { -webkit-flex-wrap: wrap; flex-wrap: wrap; }
  .clock-row label { width: 100%; -webkit-flex: 0 0 100%; flex: 0 0 100%; margin-bottom: 5px; }
  .clock-row input { margin-left: 0; }
}

@media (max-width: 360px) {
  body { font-size: 14px; }
  .panel { padding: 11px; border-radius: 15px; }
  .brand img { width: 132px; height: 58px; }
  .brand strong { font-size: 1.1rem; }
  .theme-button { padding: 0 8px; }
  .theme-button span:last-child { font-size: 12px; }
  .ip-row button { padding-left: 9px; padding-right: 9px; }
}
