* {
    box-sizing: border-box;
}

html,
body {
    max-width: 100%;
    overflow-x: hidden;
}

.ots, .cts {
  background-size: 100% 100%;
  width: 1020px;
  height: 1320px;
  margin: 4px auto;
  position: relative;
  font-family: "Google Sans", Arial, sans-serif;
  color: #000;
}

.cts {
  background: url("CTS.png") no-repeat;
  background-size: 100% 100%;
}

.sheet-scale {
  width: 1020px;
  height: 1320px;
  transform-origin: top left;
  margin: 0 auto;
}

.team-sheet {
  position: absolute;
  left: 30px;
  top: 268px;
  width: 960px;
  height: 995px;
  display: grid;
  grid-template-columns: 469px 469px;
  grid-template-rows: repeat(3, 321px);
  row-gap: 16px;
  column-gap: 18px;
}

.mon-card {
  position: relative;
  display: grid;
  grid-template-columns: 381px 90px;
  grid-template-rows: 52px 40px repeat(6, 40px);
}

.cell {
  outline: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}

[contenteditable="true"] {
  cursor: text;
  background: rgba(255, 235, 0, 0.12);
  transition: background 0.1s;
  -webkit-user-select: text;
  user-select: text;
  outline: none;
}

[contenteditable="true"]:focus {
  outline: none;
  background: rgba(255, 235, 0, 0.8);
}

.mon-name {
  grid-column: 1 / 3;
  grid-row: 1;
  padding: 13px 14px 0 120px;
  font-size: 24px;
  font-weight: 700;
}

.stat-alignment {
  grid-column: 1 / 3;
  grid-row: 2;
  padding: 7px 14px 0 120px;
  font-size: 23px;
  font-weight: 700;
}

.ability {
  grid-column: 1;
  grid-row: 3;
  padding: 7px 14px 0 120px;
  font-size: 23px;
  font-weight: 700;
}

.item {
  grid-column: 1;
  grid-row: 4;
  padding: 7px 14px 0 120px;
  font-size: 23px;
  font-weight: 700;
}

.moves {
  grid-column: 1;
  grid-row: 5 / 9;
  display: grid;
  grid-template-rows: repeat(4, 39px);
}

.moves .cell {
  padding: 6px 14px 0 120px;
  font-size: 23px;
  font-weight: 700;
}

.stats {
  grid-column: 2;
  grid-row: 3 / 9;
  display: grid;
  grid-template-rows: repeat(6, 38px);
}

.stats span {
  display: block;
  padding: 12px 4px 0;
  font-size: 14px;
  font-weight: 700;
  outline: none;
  text-align: center;
}

.sheet-info {
  position: absolute;
  inset: 0;
  font-family: "Google Sans", Arial, sans-serif;
  font-weight: 700;
  color: #000;
}

.field,
.checkbox {
  position: absolute;
  outline: none;
  cursor: text;
}

.field {
  height: 20px;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
  font-size: 14px;
  line-height: 20px;
  padding: 0 4px;
}

.player-name {
  left: 236px;
  top: 130px;
  width: 280px;
}

.trainer-name {
  left: 236px;
  top: 166px;
  width: 280px;
}

.battle-team {
  left: 236px;
  top: 202px;
  width: 280px;
}

.switch-name {
  left: 236px;
  top: 242px;
  width: 280px;
}

.player-id {
  left: 722px;
  top: 166px;
  width: 260px;
}

.dob {
  position: absolute;
  left: 722px;
  top: 202px;
  width: 260px;
  height: 20px;
  display: grid;
  grid-template-columns: 68px 68px 1fr;
  column-gap: 8px;
}

.dob > div {
  outline: none;
  overflow: hidden;
  white-space: nowrap;
  text-align: center;
  font-size: 14px;
  line-height: 20px;
  cursor: text;
}

.support-id {
  left: 722px;
  top: 242px;
  width: 260px;
}

.checkbox {
  width: 20px;
  height: 20px;
  text-align: center;
  font-size: 18px;
  line-height: 20px;
  padding: 0;
}

.juniors {
  left: 786px;
  top: 124px;
}

.seniors {
  left: 878px;
  top: 124px;
}

.masters {
  left: 961px;
  top: 124px;
}

:root {
    --bg:#c0c0c0;
    --panel:#b0b0b0;
    --panel2:#d0d0d0;
    --row:#e0e0e0;
    --text:#000;
    --border:#999;

    --gold:#ffd700;
    --silver:#c0c0c0;
    --bronze:#cd7f32;
}

html.dark body {
    --bg:#222;
    --panel:#222;
    --panel2:#333;
    --row:#1a1a1a;
    --text:#fff;
    --border:#444;

    --gold:#8a6b00;
    --silver:#7a7a7a;
    --bronze:#6a4a1f;
}

a {
    color: black;
}

a:hover {
    color: white;
    background: #0099ff;
}

body {
    margin: 0;
    background: var(--bg);
    font-family: "Google Sans", Tahoma, Arial, sans-serif;
    color: var(--text);
}

.window {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.titlebar {
    background: #808080;
    color: #fff;
    padding: 4px;
    font-weight: bold;
    font-size: 12px;
    line-height: 1.25;
}

.content {
    flex: 1;
    padding: 6px;
    text-align: center;
    margin: 0 auto;
    width: 100%;
    overflow: hidden;
}

.nav {
    margin: 6px 24px 0;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.nav br {
    display: none;
}

#themeBtn {
    width: 40px;
    height: 40px;
    padding: 4px;
    font-size: 18px;
    background: transparent !important;
    border: none !important;
}

button,
select {
    transition: background .15s ease, color .15s ease;
}

button:hover,
select:hover {
    background: var(--panel2);
    color: var(--text);
}

body.dark button:hover,
body.dark select:hover {
    background: var(--panel2);
    color: var(--text);
}

#themeBtn button {
    background: transparent !important;
    border: none !important;
}

.pokemon-wrap {
    grid-column: 3;
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 4px;
}

button {
    min-height: 38px;
    padding: 8px 12px;
    background: var(--panel2);
    border: 1px solid var(--border);
    cursor: pointer;
    font: inherit;
    font-size: 11px;
    color: var(--text);
}

.controls {
    display: flex;
    gap: 8px;
    margin-top: 8px;
}

.bottom-box {
    margin-top: 16px;
    display: flex;
    justify-content: center;
}

.type.grass { background:#7AC74C; }
.type.poison { background:#A33EA1; }
.type.fire { background:#EE8130; }
.type.water { background:#6390F0; }
.type.electric { background:#F7D02C; color:#111; }
.type.ice { background:#96D9D6; color:#111; }
.type.fighting { background:#C22E28; }
.type.ground { background:#E2BF65; color:#111; }
.type.flying { background:#A98FF3; }
.type.psychic { background:#F95587; }
.type.bug { background:#A6B91A; }
.type.rock { background:#B6A136; }
.type.ghost { background:#735797; }
.type.dragon { background:#6F35FC; }
.type.dark { background:#705746; }
.type.steel { background:#B7B7CE; color:#111; }
.type.fairy { background:#D685AD; }
.type.normal { background:#A8A77A; }

table {
    background: var(--panel);
    color: var(--text);
}

th,
td {
    border: 1px solid var(--border);
    padding: 6px;
    text-align: center;
    background: var(--row);
}

th {
    background: var(--panel2);
    position: sticky;
    top: 0;
    z-index: 1;
    font-weight: bold;
}

tr:hover td {
    background: var(--panel2);
}

.team-modal {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 1;
    transition: opacity 0.2s ease;
    z-index: 9999;
}

.team-modal.hidden {
    pointer-events: none;
    opacity: 0;
}

.team-box {
    width: min(600px, 100%);
    max-height: calc(100vh - 32px);
    overflow: auto;
    background: white;
    padding: 12px;
    border-radius: 8px;
    border: 1px solid var(--text);
}

.dark .team-box {
    background: #111;
    color: #fff;
}

#teamInput {
    width: 100%;
    height: 260px;
    resize: vertical;
    font: 14px monospace;
}

.team-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}

.team-actions button {
    padding: 4px;
}

.exporting [contenteditable="true"] {
    background: transparent !important;
    outline: none !important;
    box-shadow: none !important;
    caret-color: transparent !important;
}

.exporting-ots .stats span {
    color: transparent !important;
}

.exporting-ots .player-id,
.exporting-ots .dob,
.exporting-ots .support-id {
    color: transparent !important;
}

.exporting-ots .cts {
    background-image: url("OTS.png") !important;
}

@media (max-width: 720px) {
    body {
        padding: 0px;
    }

    .titlebar {
        font-size: 15px;
    }

    .titlebar small {
        margin-left: 44px !important;
    }

    .nav {
        margin: 6px 4px 0;
        display: grid;
        grid-template-columns: 1fr;
        gap: 6px;
    }

    .nav button {
        width: 100%;
    }

    .content {
        padding: 4px;
        margin-top: 8px;
    }

    .team-modal {
        align-items: flex-start;
    }

    #teamInput {
        min-height: 260px;
    }
}