/* Battleship is deliberately rendered as a text terminal. */
html,
body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: #000;
}

body {
  margin: 8px;
}

body,
button,
input {
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  line-height: 1.2;
}

button,
input {
  color: #000;
}

button {
  cursor: pointer;
}

button:disabled {
  color: #000;
  cursor: default;
}

[hidden] {
  display: none !important;
}

.shell {
  width: auto;
  margin: 0;
  padding: 0 0 24px;
}

.screen {
  width: 100%;
}

.start-screen {
  width: 100%;
  margin: 0;
  padding: 0;
}

/* The reference page starts with a full-width black console. */
.console-window {
  position: relative;
  width: 100%;
  height: 104px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
}

.console-history,
.console-prompt {
  position: absolute;
  left: 8px;
  margin: 0;
  padding: 0;
  font-family: "Times New Roman", Times, serif;
  font-size: 14px;
  font-weight: normal;
  line-height: 1.2;
  white-space: pre;
}

.console-history {
  top: 12px;
  color: #fff;
}

.console-prompt {
  bottom: 12px;
  color: #fff;
}

.console-cursor {
  color: #fff;
}

.start-content {
  width: 275px;
  margin: 0;
  padding: 14px 0 0;
}

.ascii-title,
.ascii-rule,
.ascii-board,
.players-strip,
.ship-status {
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  font-weight: normal;
  white-space: pre;
}

.ascii-title {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.1;
}

.ascii-rule {
  width: 275px;
  margin: 8px 0;
  padding: 0;
  overflow: hidden;
  line-height: 1.1;
}

.eyebrow,
.control-title,
label {
  font-weight: bold;
}

.eyebrow {
  margin: 8px 0 4px;
  font-size: 14px;
  line-height: 1.1;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: 26px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.1;
}

.lede {
  width: 275px;
  margin-bottom: 18px;
}

.entry-form {
  margin-top: 0;
}

label {
  display: block;
  margin: 8px 0 2px;
}

.input-line {
  display: block;
  margin: 2px 0 10px;
  white-space: nowrap;
}

.input-line input {
  width: 210px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  background: transparent;
  font: inherit;
}

.input-line input:focus {
  outline: 0;
}

/* Small, old-browser-looking controls, with the command still visible as text. */
.button {
  margin: 4px 8px 4px 0;
  padding: 2px 4px;
  border: 1px solid #1a1a1a;
  border-radius: 2px;
  background: #eee;
  color: #000;
  font: inherit;
  font-size: 12px;
  font-weight: normal;
  line-height: 1.1;
  vertical-align: middle;
  outline: 0;
}

.button:hover,
.button:focus {
  background: #ddd;
}

.button:active {
  background: #ccc;
}

.button:disabled {
  border-color: #fff;
  background: #eee;
  opacity: .6;
}

.wide {
  display: block;
}

.join-row {
  margin-top: 12px;
  padding-top: 0;
}

.join-controls {
  white-space: nowrap;
}

.join-controls .input-line {
  display: inline-block;
  margin-right: 8px;
}

.form-error {
  min-height: 18px;
  margin: 8px 0;
}

/* The in-game header is the same console treatment as the landing screen. */
.game-screen {
  width: 100%;
  max-width: none;
}

.game-header {
  position: relative;
  width: 100%;
  max-width: none;
  height: 104px;
  margin: 0;
  padding: 0;
  overflow: hidden;
  background: #000;
  color: #fff;
}

.game-header > div:first-of-type {
  position: absolute;
  left: 8px;
  bottom: 10px;
}

.game-header .eyebrow {
  margin: 0 0 4px;
  color: #fff;
}

.game-header h1 {
  margin: 0;
  color: #fff;
  font-size: 22px;
}

.game-header .console-history {
  top: 12px;
  left: 8px;
}

.header-actions {
  position: absolute;
  right: 8px;
  bottom: 10px;
  width: auto;
  white-space: nowrap;
}

.room-code {
  letter-spacing: 2px;
}

.game-screen > .ascii-rule {
  width: 275px;
}

.connection-banner {
  width: 760px;
  max-width: 100%;
  margin: 8px 0;
  white-space: pre-wrap;
}

.players-strip {
  width: 760px;
  max-width: 100%;
  min-height: 1.4em;
  margin: 8px 0;
  white-space: pre-wrap;
}

.game-message {
  width: 760px;
  max-width: 100%;
  min-height: 20px;
  margin: 8px 0;
}

.panel {
  width: 760px;
  max-width: 100%;
  margin: 0;
  padding: 0;
}

.panel-heading {
  display: table;
  width: 760px;
  max-width: 100%;
  margin: 8px 0;
}

.panel-heading > div {
  display: table-cell;
  vertical-align: bottom;
}

.state-line {
  display: table-cell;
  width: 42%;
  font-weight: bold;
  white-space: nowrap;
  text-align: right;
  vertical-align: bottom;
}

.setup-layout,
.battle-layout {
  display: table;
  width: 760px;
  max-width: 100%;
  table-layout: fixed;
}

.setup-layout .board-wrap,
.setup-layout .fleet-controls,
.battle-layout .board-wrap {
  display: table-cell;
  vertical-align: top;
}

.setup-layout .board-wrap {
  width: 356px;
  padding: 12px 0 18px;
}

.setup-layout .fleet-controls {
  width: 275px;
  padding: 12px 0 18px 18px;
}

.battle-layout {
  width: 728px;
}

.battle-layout .board-wrap {
  width: 356px;
  padding: 12px 0 18px;
}

.battle-layout .board-wrap + .board-wrap {
  padding-left: 16px;
}

.board-label-row {
  width: 356px;
  margin: 4px 0;
  font-weight: bold;
  white-space: nowrap;
}

.axis-hint {
  margin-left: 18px;
  font-size: 14px;
  font-weight: normal;
}

/* The board frame and every cell are characters. CSS draws no grid lines. */
.ascii-board {
  display: block;
  width: 356px;
  margin: 8px 0;
  padding: 0;
  overflow: visible;
}

.ascii-board-table {
  width: 356px;
  table-layout: fixed;
  border: 0;
  border-collapse: collapse;
  margin: 8px 0;
  padding: 0;
  font: inherit;
  white-space: nowrap;
}

.ascii-board-table td {
  height: 23px;
  margin: 0;
  padding: 0;
  text-align: center;
  vertical-align: middle;
}

.ascii-board-table .ascii-row-label {
  width: 24px;
  text-align: right;
  padding-right: 4px;
}

.ascii-board-table .ascii-pipe {
  width: 8px;
}

.ascii-board-table .ascii-segment,
.ascii-board-table .ascii-column-label,
.ascii-board-table .ascii-cell-wrap {
  width: 24px;
  text-align: center;
}

.ascii-cell {
  display: block;
  width: 24px;
  min-width: 0;
  height: 23px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  font: inherit;
  font-weight: bold;
  line-height: 23px;
}

.ascii-cell:hover,
.ascii-cell:focus {
  background: transparent;
  text-decoration: underline;
  outline: 0;
}

.ascii-cell:disabled {
  color: #000;
  opacity: 1;
}

.legend,
.small-note {
  width: 356px;
  margin: 6px 0;
  font-size: 14px;
}

.fleet-controls {
  margin: 0;
}

.fleet-list {
  margin: 4px 0 10px;
}

.fleet-item {
  margin: 3px 0;
}

.fleet-item button {
  margin: 0 14px 0 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #000;
  font: inherit;
  text-align: left;
}

.fleet-item button:hover,
.fleet-item button:focus {
  outline: 0;
  text-decoration: underline;
}

.fleet-badge {
  white-space: nowrap;
}

.orientation-row,
.control-actions {
  margin: 8px 0;
}

.control-actions .button {
  margin-right: 8px;
}

.battle-footer {
  width: 728px;
  margin: 12px 0;
}

.last-action {
  min-height: 20px;
  margin: 0 0 8px;
}

.ship-status {
  margin: 0;
  white-space: pre-wrap;
}

.finish-panel {
  width: 275px;
  text-align: left;
}

.finish-panel h2 {
  margin-bottom: 8px;
}

.finish-panel p:not(.eyebrow) {
  margin-bottom: 18px;
}

.toast {
  position: fixed;
  left: 12px;
  bottom: 12px;
  z-index: 5;
  max-width: 700px;
  padding: 0;
  background: #fff;
  color: #000;
  visibility: hidden;
}

.toast.show {
  visibility: visible;
}

/* Older narrow screens keep the fixed character width, but flow the columns
   downward so every control remains reachable without a sideways board. */
@media only screen and (max-width: 760px) {
  body {
    margin: 2px;
  }

  .game-header {
    height: auto;
    min-height: 104px;
    padding-bottom: 8px;
    overflow: hidden;
  }

  .game-header > div:first-of-type {
    position: static;
    padding: 54px 8px 0;
  }

  .game-header h1 {
    max-width: 100%;
    font-size: 20px;
    white-space: normal;
  }

  .header-actions {
    position: static;
    margin: 8px;
    white-space: normal;
  }

  .connection-banner,
  .players-strip,
  .game-message,
  .panel,
  .panel-heading {
    width: 356px;
    max-width: 100%;
  }

  .panel-heading {
    display: block;
  }

  .panel-heading > div,
  .state-line {
    display: block;
    width: auto;
    text-align: left;
  }

  .state-line {
    margin-top: 4px;
  }

  .setup-layout,
  .battle-layout {
    display: block;
    width: 356px;
    max-width: 100%;
  }

  .setup-layout .board-wrap,
  .setup-layout .fleet-controls,
  .battle-layout .board-wrap {
    display: block;
    width: 356px;
    max-width: 100%;
    padding: 12px 0 18px;
  }

  .setup-layout .fleet-controls {
    padding-left: 0;
  }

  .battle-layout .board-wrap + .board-wrap {
    padding-left: 0;
  }

  .battle-footer,
  .legend,
  .small-note {
    width: 356px;
    max-width: 100%;
  }

  .board-label-row {
    max-width: 100%;
    white-space: normal;
  }
}

/* Keep the character grid inside very narrow phone viewports as well. */
@media only screen and (max-width: 360px) {
  .connection-banner,
  .players-strip,
  .game-message,
  .panel,
  .panel-heading,
  .setup-layout,
  .battle-layout,
  .battle-footer,
  .legend,
  .small-note {
    width: 316px;
  }

  .setup-layout .board-wrap,
  .setup-layout .fleet-controls,
  .battle-layout .board-wrap {
    width: 316px;
  }

  .board-label-row,
  .ascii-board,
  .ascii-board-table {
    width: 316px;
  }

  .ascii-board-table td {
    height: 21px;
  }

  .ascii-board-table .ascii-row-label {
    width: 20px;
    padding-right: 2px;
  }

  .ascii-board-table .ascii-pipe {
    width: 6px;
  }

  .ascii-board-table .ascii-segment,
  .ascii-board-table .ascii-column-label,
  .ascii-board-table .ascii-cell-wrap {
    width: 20px;
  }

  .ascii-cell {
    width: 20px;
    height: 21px;
    line-height: 21px;
  }
}

/* Below the 320px layout target, keep the page itself fitted while allowing
   the fixed-width character board to be inspected horizontally in its column. */
@media only screen and (max-width: 319px) {
  .connection-banner,
  .players-strip,
  .game-message,
  .panel,
  .panel-heading,
  .setup-layout,
  .battle-layout,
  .battle-footer,
  .legend,
  .small-note {
    width: 100%;
    max-width: 100%;
  }

  .setup-layout .board-wrap,
  .setup-layout .fleet-controls,
  .battle-layout .board-wrap {
    width: 100%;
    max-width: 100%;
  }

  .setup-layout .board-wrap,
  .battle-layout .board-wrap {
    overflow-x: auto;
  }

  .legend,
  .small-note {
    white-space: normal;
  }
}
